artisticat1 / obsidian-tikzjax

Render LaTeX and TikZ diagrams in your notes
MIT License
457 stars 27 forks source link

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

Open ALTONPHA opened 11 months ago

ALTONPHA commented 11 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 8 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 5 months ago

FIY: This is the same issue as #25.

thecodechemist99 commented 5 months 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 5 months 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.

thecodechemist99 commented 4 months ago

I managed to update the TeX engine within the plugin and added support for the \expanded primitive which lets me now use the latest chemfig package version (see web2js and tikzjax).

The issue with reaction schemes still remains, unfortunately, but now at least it throws an error:

chemfig_log_latest-latest

Unfortunately, so far I have no idea where this originates from and how to resolve it.

softedco commented 2 months ago

is there a workaround for this for now? would be very helpful

ALTONPHA commented 2 months ago

is there a workaround for this for now? would be very helpful

Although there is no way to make this code effect properly, you can use it indirectly.

Screenshot 2024-09-08 at 5 52 07 PM

The code show as follow:

\usepackage{chemfig}
\begin{document}
\chemfig[bond style={line width=1pt},atom sep=2em,cram width=5pt,bond join=true,fixed length=true]{HC(-[6,,2]COO^{-})(-\chemabove{N}{+}H_3)-[2,,2]CH_2-[2]COO^{-}}
\chemname{
    \schemestart
    \arrow{-U>[ATP][ADP][][][45]}[,3]
    \schemestop
}{aspartokinase}
\chemfig[bond style={line width=1pt},atom sep=2em,cram width=5pt,bond join=true,fixed length=true]{HC(-[6,,2]COO^{-})(-\chemabove{N}{+}H_3)-[2,,2]CH_2-[2]C(=[2]O)-O-PO_3^{2+}}
\chemname{
    \schemestart
    \arrow{-U>[NADPH][NAD\chemfig{\chemabove{P}{+}}+Pi][][][45]}[,3]
    \schemestop
}{asparate-$\beta$-semialdehyde dehydrogenase}
\chemfig[bond style={line width=1pt},atom sep=2em,cram width=5pt,bond join=true,fixed length=true]{HC(-[6,,2]COO^{-})(-\chemabove{N}{+}H_3)-[2,,2]CH_2-[2]C(=[2]O)-H}
\chemname{
    \schemestart
    \arrow{-U>[NADPH+H$^+$][NAD\chemfig{\chemabove{P}{+}}][][][45]}[,2]
    \schemestop
}{dehydrogenase}
\chemfig[bond style={line width=1pt},atom sep=2em,cram width=5pt,bond join=true,fixed length=true]{HC(-[6,,2]COO^{-})(-\chemabove{N}{+}H_3)-[2,,2]CH_2-[2]CH_2OH}
\end{document}

You can put your \chemfig{} structure outside the \schemestart \schemstop to use the arrow.