chemfig drawing renders incorrectly
Brought to you by:
baudinr
My university lab reports must be submitted in an MS Word compatible format. I have been using TeXMaths (add \usepackage{chemfig} to the preamble) for most of the 'casual' chemistry markup that I need to do (typically describing functional groups inline). I wanted to try something more ambitious. The following snippet produces correct output in LaTeX, but slightly incorrect output through TeXMaths (the blue arrows are incorrectly placed).
\begin{minipage}{\linewidth}
\vspace{5mm}
\makebox[\linewidth]{
\schemestart
\chemfig{@{cl}Cl -[@{b}] @{cr}Cl}
\arrow{->[$\lambda$][]}
\chemfig{\charge{0=\.}{Cl}}
\+
\chemfig{\charge{180=\.}{Cl}}
\schemestop
\chemmove[blue,shorten <=2pt,shorten >=2pt]{
\draw[-{Stealth[right]}](b)..controls +(90:5mm) and +(70:5mm)..(cl);
\draw[-{Stealth[right]}](b)..controls +(-90:5mm) and +(-110:5mm)..(cr);}
}
\vspace{5mm}
\end{minipage}
I did several tests and it seems that the dvi file produced using the latex (or pdflatex) command is corrupted for your equation (the blue arrow is misplaced).
Then of course, the dvi -> svg conversion (using dvisvgm tool) gives a misplaced arrow.
As you found, if a dvi file is not produced, then the arrow is correctly placed.
So my guess is there is a bug in the latex or pdflatex program that occurs when outputting a dvi file.
After some more testing of my own, I realized there may be something else at work here that I've seen used in other contexts before:
The arrows are governed by anchors /placement ids that go into the chemical equations themselves. The latex process needs to be run more than once: Once to establish the position of the anchors in the document, and again to draw them in the correct place.
I may try to elevate this to chemfig; except for the fact that I'm just about done with my Organic Chemistry class for this semester. I don't know that there's anything TexMaths can do to make that work.