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

Brackets inside stem macro and block are not properly rendered. #67

Closed jfernandz closed 4 years ago

jfernandz commented 4 years ago

Well, here the MWE

:stem: latexmath

== This is a test

[stem]
++++
NH_4NO_2(s)
++++

. Now inside a list item stem:[NH_4NO_2(s)]

This is the result I'm getting after conversion with

asciidoctor-pdf -r asciidoctor-mathematical -o test.pdf test.adoc

Captura de pantalla_2019-12-20_14-32-31

ProgramFan commented 4 years ago

Would you please check if it works under asciidoctor alone in the html renderer? It seems that you are lacking some fonts.

jfernandz commented 4 years ago

For .html format is all working as expected.

jfernandz commented 4 years ago

@ProgramFan I've also detected problems in single letters rendering, it is rendering them like superscripts as you can see in the screenshot. Otherwise the test.html file is properly rendered when I get it from asciidoctor test.adoc

Captura de pantalla_2019-12-20_16-59-22

ProgramFan commented 4 years ago

I can confirm the rendering of brackets is an issue of missing fonts. Install all fonts as stated in mathematical page https://github.com/gjtorikian/mathematical. This is what I get on macOS:

图片

The i and n problem is caused by the font size, which, however, does not have any solutions yet.

jfernandz commented 4 years ago

@ProgramFan well, you were right about fonts, I've solved the issue installing this package in Arch; however

ProgramFan commented 4 years ago

The issue is considered invalid because asciidoctor-mathematical can do nothing since it is caused by mathematical itself. Whether mathematical will consider it an issue depends on mathematical itself.

For the stem-xxxxx.png, unfortunately, asciidoctor-mathematical can not delete them on its own. asciidoctor-mathematical is meant to be used as a plugin, so you can use it with the pdf, html, docbook and even epub3 backend. Only the pdf backend can safely remove the files after pdf generation. If you care about this, use a makefile do build pdf and clean the stem pngs at the same time.

For the first suggestion, an PR is welcome.

jfernandz commented 4 years ago

@ProgramFan Are devs aware about this font issue in the mathematical repo? (I guess they are.)

ProgramFan commented 4 years ago

They are and they have instructions in the repo README. But they only have instructions for osx.

jfernandz commented 4 years ago

Excuse me, could you specify where exactly those instructions are? I was reading the readme and I could not find them.

ProgramFan commented 4 years ago
cd ~/Library/Fonts
curl -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmex10.ttf \
     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmmi10.ttf \
     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmr10.ttf \
     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmsy10.ttf \
     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/esint10.ttf \
     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/eufm10.ttf \
     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/msam10.ttf \
     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/msbm10.ttf
jfernandz commented 4 years ago

But that's for install the fonts, what has that to do with font size, which is causing the issue for single letters size?

Are those maybe fixed ones? Because in that case I could create a new AUR package to ship them to the system. As I've pointed in #68 those fonts are packaged in this one but even those are causing the smaller size than normal.

The package I mention fetches the fonts from http://distfiles.gentoo.org/distfiles/texcm-ttf.zip which is not exactly the same site than mathematical repo suggests, that's why I'm asking if there would be a difference and this size issue could be fixed shipping the suggested ones.

EDIT: In fact I would not need to package those .ttf fonts because the lyx package has them, like you can see in its file list

EDIT2: I've realised you probably misunderstood me; I was talking about the font size issue, not my problem with parenthesis rendering. On the other hand ... I've also noticed that lyx package is not really shipping the fonts to the right folder so they make them unusable in systemwide unless you copy them to some of the right paths: /usr/share/fonts or ~/.local/share/fonts. Due this I would recommend the ttf-computer-modern-fonts package, which it makes the fonts systemwide usable.

ProgramFan commented 4 years ago

Sorry to have misunderstood the issue. Based on my own experience, I have no idea how to deal with the font size problem. Mathematical converts the latex equation to MML and uses Lasem to convert MML to png and SVG. After the conversion, all font information is lost and only path information is recorded. So it can only be typeset as a fix-sized inline image and unfortunately, the produced image is just too small.

I would suggest you not to rely on this package for publication, but for drafting. For publication, asciidoctor + asciidoctor-latex + asciidoctor-bibtex is more friendly to play with.

jfernandz commented 4 years ago

Well, @ProgramFan I appreciate your help and suggestions, but the point with asciidoctor-latex is that's not working as expected either, as you can see in here is not treating properly in-line expressions or math expressions inside items list or tables.