artisticat1 / obsidian-tikzjax

Render LaTeX and TikZ diagrams in your notes
MIT License
356 stars 18 forks source link

There is a problem about \schemestart<response equation>\schemestop #54

Open ALTONPHA opened 6 months ago

ALTONPHA commented 6 months ago

As shown in the figure below, after using the \subscheme command, chemical bonds are no longer displayed and only atoms can be displayed.

Screenshot 2023-12-29 at 3 53 01 PM Screenshot 2023-12-29 at 3 53 23 PM
Sunlordi commented 3 months ago

Yeap, this is a real problem. I was so glad to find I can write my chemical notes with that plugin, and reactions is a really key part of that. But still I'm very appreciate to authors for plugin. I believe this bug will be fixed. Script lose one argument [stroke=""] under bond description. Adding this argument through DevTool change the situation (see selected string and last one) изображение

thecodechemist99 commented 6 days ago

FIY: This is the same issue as #25.

thecodechemist99 commented 6 days ago

Script lose one argument [stroke=""] under bond description. Adding this argument through DevTool change the situation (see selected string and last one) !

The issue is actually on the <g> tag above, setting stroke="none" for all child elements. If you remove this, all the bonds are shown in black. Unfortunately also the white ones, if present.

Below is an example where I removed the stroke=none command for the left side of the equation: scheme_example

And this is the corresponding tikzjax code:

\standaloneconfig{border=1pt}
\usepackage{chemfig}
\tikzset{
    bold bond/.style = {line width = 0.22832 em},
    dash bond/.style = {
        dash pattern = on 0.25737 em off 0.25737 em,
    },
    hash bond/.style = {
        dash pattern = on 0.25737 em off 0.25737 em,
        line width = 0.22832 em,
    },
}
\setchemfig{
    double bond sep=0.35700 em,
    atom sep=1.78500 em,
    bond offset=0.18265 em,
    bond style={
        line width=0.06642 em,
    },
}
\begin{document}
\renewcommand*\printatom[1]{\ensuremath{\mathsf{#1}}}

\schemestart
\chemname{\chemfig[cram width=2pt]{*6((=)-(=O)-O\rlap{${}^{\scriptstyle\ominus}$}-[,,,,,white]-[,,,,,white]-[,,,,,white]O(-P(=[::-90]O)(-[::90]HO)(-[::0]HO))-)}}{Phosphenolpyruvat}
\,\,\,
+
\,\,\,
\chemname{\chemfig[cram width=2pt]{*6((<:-[::-60]O-P(=[::-90]O)(-[::90]OH)(-[::0]HO))-(<:OH)-(=[2]O)(-H)-[,,,,,white]-[,,,,,white]-[,,,1,,white]OH-)}}{Erythrose-4-phosphat}
\,\,\,
\arrow[,0.6]
\,\,\,
\chemname{\chemfig[cram width=2pt]{*6((<:HO)-(<OH)--(-(=[2]O)-[::-60]O\rlap{${}^{\scriptstyle\ominus}$})=-(<:HO)-)}}{Shikimat-Anion}
\schemestop

\end{document}

The issue seems to affect all line-based bonds. The filled cram bonds actually work just fine: scheme_example_2

thecodechemist99 commented 6 days ago

I extracted the intermediate dvi buffer for my previous example (the first one) from within the tikzjax code. It looks like the dvi is already broken, for some reason actually more than the final output but the bond lines are definitely already missing (screenshot from dvi file opened in TeXShop):

dvi_texshop

I also verified that my extraction procedure worked correctly by inserting a dvi file created from the same source code via LaTeX base64 encoded into the tikzjax code. After the same extraction procedure it produced the correct output:

dvi_reference_texshop

Interestingly, the inserted and obviously correct dvi file did not produce a correct output in Obsidian but an error instead:

dvi_reference_error

If I interpret this correctly, the bond line rendering issue seems to be introduced by the tex.wasm code, meaning further debugging has to take place there. There also seems to be another bug or at least partially missing implementation in tikzjax afterwards, possibly in dvi2html.