1

I'm using overleaf as my latex editor and I have a problem with the arrows in my reaction mechanism, the blue ones are how they should be, but they stay in the first molecule (red arrows)

\tikzset{obrace/.style={left delimiter={[},inner sep=3pt},
    cbrace/.style={right delimiter={]},inner sep=3pt},
    braces/.style={left delimiter={[},right delimiter={]},inner sep=3pt}}
\setchemfig{atom sep=2em}
\schemestart
\chemfig{H-C(=[:60]O)-[:-60]O-H}
\arrow(--M1[obrace]){-U>[\scriptsize\chemfig{H_2SO_4^{}}][\scriptsize\chemfig{HSO_4^\ominus}][][.25]}
[,1.5,shorten >=6pt]
\chemfig{H-@{a2}C(-[:60]O-H)(-[:30,.5,,,draw=none]{\scriptstyle\oplus})-[:-60]O-H}
\arrow(--[cbrace]){<->}
\chemfig{H-C(=[:60]\chemabove{O}{\scriptstyle\oplus}-H)-[:-60]O-H}
\arrow(@M1--){<=>[*{0}\scriptsize\chemfig{H-[:120]@{a1}O-[:60]CH_3}][*{0}\tiny addition]}[-90,1.33]
\chemfig{H-C(-[2]O-[:30]H)(-\chemabove{O}{\scriptstyle\oplus}(-[:60]CH_3)-[:-60]H)-[6]O-[:-30]H}
\arrow{<=>[\tiny protolysis]}[180]
\chemfig{H-C(-[2]O-[:30]H)(-O-CH_3)-[@{B1}6]@{a3}O(-[:-150]H)-[:-30]H}
\arrow(--[obrace]){<=>[*{0}\scriptsize\chemfig{{-}H_2O}][*{0}\tiny elimination]}[-90,,shorten >=6pt]
\chemfig{H-C(-[:60]O-H)(-[,.5,,,draw=none]{\scriptstyle\oplus})-[:-60]O-CH_3}
\arrow(--[cbrace]){<->}
\chemfig{H-C(=[:60]\chemabove{O}{\scriptstyle\oplus}-H)-[:-60]O-CH_3}
\arrow{-U>[\scriptsize\chemfig{HSO_4^\ominus}][\scriptsize\chemfig{H_2SO_4^{}}][][.25]}[,1.5]
\chemfig{H-C(=[:60]O)-[:-60]O-CH_3}
\arrow(@M1--[yshift=-5pt]){0}[180,.5]{\tiny protolysis}
\schemestop
\chemmove[red,shorten <=3pt, shorten >=1pt]{
    \draw(a1)..controls +(0:1.5cm)and+(0:3cm)..(a2);
    \draw(B1)..controls +(0:5mm)and+(5:5mm)..(a3);}

enter image description here

Even with an easier example I have the same problem, the red arrow should go to the H above the arrow and not to the R1, and playing with the code I found that when I dont use the \arrow between molecules (only +) the mechanism arrows go where they are supposed to, does anybody now how I can solve this, if it is an Overleaf problem or do I need an specific package

\setchemfig{atom sep=7mm}
\schemestart
\chemfig{R1-@{dnl}\lewis{2:6:,O}-H}
\+
\chemfig{R2-@{atoc}C([6]-OH)=[@{db}]O}
\arrow(.mid east--){<->[\chemfig{ @{atoh}H}]}
\chemfig{R2-C([6]-OH)(-[2]O(-[1]H)-[3]R1)-OH}
\schemestop
\chemmove[shorten <=2pt]{
\draw(dnl)..controls +(90:1cm)and+(north:1cm)..(atoc);
\draw[red, shorten >=6pt](db)..controls +(north:5mm)and+(100:1cm)..(atoh);}

enter image description here

Javier
  • 13
  • Try to compile with lualatex – polyn Feb 26 '20 at 16:14
  • 1
    I copy/pasted your code into Overleaf (shich as you say you use), just added the bare minimum to make it a complete example and there is no such problem: https://www.overleaf.com/read/xhybqmcqrzbc – cgnieder Feb 26 '20 at 18:02
  • Thank you both for taking your time in helping me, I was compilating in XeLateX, I've changed to LuaLatex and now it works perfectly. – Javier Feb 26 '20 at 23:09
  • You should have mentioned in your question that you used XeLaTeX – cgnieder Feb 28 '20 at 21:36

1 Answers1

2

This issue is discussed here: How to fix chemfig's chemmove in XeTeX and a solution is provided here: tikzmark and xelatex and here: Incorrect positioning when using tikz overlay and remember picture. It is a known XeLaTeX issue.

The second and third links provide the same solution, which is implemented below. Compile twice with XeLaTeX.

\documentclass[border=3pt]{standalone}
\usepackage{chemfig}

\makeatletter
\def\pgfsys@hboxsynced#1{%
  {%
    \pgfsys@beginscope%
    \setbox\pgf@hbox=\hbox{%
      \hskip\pgf@pt@x%
      \raise\pgf@pt@y\hbox{%
        \pgf@pt@x=0pt%
        \pgf@pt@y=0pt%
        \special{pdf: content q}%
        \pgflowlevelsynccm%
        \pgfsys@invoke{q -1 0 0 -1 0 0 cm}%
        \special{pdf: content -1 0 0 -1 0 0 cm q}% translate to original coordinate system
        \pgfsys@invoke{0 J [] 0 d}% reset line cap and dash
        \wd#1=0pt%
        \ht#1=0pt%
        \dp#1=0pt%
        \box#1%
        \pgfsys@invoke{n Q Q Q}%
      }%
      \hss%
    }%
    \wd\pgf@hbox=0pt%
    \ht\pgf@hbox=0pt%
    \dp\pgf@hbox=0pt%
    \pgfsys@hbox\pgf@hbox%
    \pgfsys@endscope%
  }%
}
\makeatother

\begin{document}

\setchemfig{atom sep=7mm}
\schemestart
\chemfig{R1-@{dnl}\lewis{2:6:,O}-H}
\+
\chemfig{R2-@{atoc}C([6]-OH)=[@{db}]O}
\arrow(.mid east--){<->[\chemfig{ @{atoh}H}]}
\chemfig{R2-C([6]-OH)(-[2]O(-[1]H)-[3]R1)-OH}
\schemestop
\chemmove[shorten <=2pt]{
\draw(dnl)..controls +(90:1cm)and+(north:1cm)..(atoc);
\draw[red, shorten >=6pt](db)..controls +(north:5mm)and+(100:1cm)..(atoh);}

\end{document}

enter image description here

Alternatively, as already was suggested, you can compile with LuaLaTeX.

Ross
  • 5,656
  • 2
  • 14
  • 38