3

I got the following problem. When I draw a <-> arrow with chemfig it has a gap in the middle. The funny thing is the gap is only if my arrow goes from right to left. Vertical arrows are drawn properly. I have made an example but in the example it is the other way around. The arrow from left to right is not fully drawn while from right to left is.

\documentclass{scrartcl}
\usepackage{chemfig}
\begin{document}    
\schemestart
    \chemfig{*6(------)}
    \arrow{<->}
    \chemfig{*6(------)}
    \arrow{<->}[90]
    \chemfig{*6(------)}
    \arrow{<->}[180]
    \chemfig{*6(------)}
\schemestop
\end{document}

Example

Does anyone have an idea? I went throgh the documentation of chemfig already but couldnt find anything. Greetings Moritz

1

EDIT: The issue described in the question is reproducible with version 1.31 of chemfig (from where the 'original definition' of the <-> arrow is taken). With version 1.34 ther issue does not occur any more and the desired output is obtained.


The following example contains a modified version of the <-> arrow type that does not show the gap if it is rotated by 180°

\documentclass{scrartcl}
\usepackage{chemfig}

\makeatletter
\definearrow3{<->}{%
    \CF@arrow@shift@nodes{#3}%
    \path(\CF@arrow@start@node)--(\CF@arrow@end@node)%
            node[pos=0.5,sloped](\CF@arrow@start@node1){}node[pos=0.5,sloped](\CF@arrow@end@node1){};%
    \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node1)--(\CF@arrow@end@node);%
    \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@end@node1)--(\CF@arrow@start@node);%
    \CF@arrow@display@label{#1}{0.5}+\CF@arrow@start@node{#2}{0.5}-\CF@arrow@end@node
}
\makeatother

\begin{document}    
\schemestart
    \chemfig{*6(------)}
    \arrow{<->}[0]
    \chemfig{*6(------)}
    \arrow{<->}[-90]
    \chemfig{*6(------)}
    \arrow{<->}[180]
    \chemfig{*6(------)}
\schemestop
\end{document}

enter image description here

If you compare this with the original definition from chemfig.tex

\definearrow3{<->}{%
    \CF@arrow@shift@nodes{#3}%
    \path(\CF@arrow@start@node)--(\CF@arrow@end@node)%
            node[pos=0.5,sloped,xshift=-1pt](\CF@arrow@start@node1){}node[pos=0.5,sloped,xshift=1pt](\CF@arrow@end@node1){};%
    \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node1)--(\CF@arrow@end@node);%
    \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@end@node1)--(\CF@arrow@start@node);%
    \CF@arrow@display@label{#1}{0.5}+\CF@arrow@start@node{#2}{0.5}-\CF@arrow@end@node
}

you can see, that I have removed the xshift options.

  • 2
    This looks very advanced (+1) but could you perhaps explain a bit more? Do you think there is a bug in chemfig? And could you perhaps explain why it is necessary to draw a double-headed arrow in this way? TikZ does support double-headed arrows out of the box. – user121799 Feb 23 at 20:51
  • 1
    @marmot: To be honest, the above example is just the result of me experimenting with the original code of the <-> type arrow. I noticed the xshift option and suspected this to be the culprit for the gap. – leandriis Feb 23 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.