6

How can one make a forked arrow in chemfig?

Semantically it is exactly opposite to \merge command but seems like it's not implemented in a package. I don't have any experience with TikZ graphics but any solution would be highly appreciated.

I'd like to get something like the following scheme:

forked Scheme

2 Answers 2

7

Since you can use \chemfig inside a tikzpicture environment, you can place the three compounds (forgive me if that's not the right name) inside \nodes and then use \draw to draw the arrows:

\documentclass{article}
\usepackage{chemfig}
\usetikzlibrary{positioning,calc}

\begin{document}

\definesubmol\Me[H_3C]{CH_3}

\begin{tikzpicture}[node distance=0cm and 2cm]
\node (A) 
  {\chemfig{R-C-[::-60]O-[::-60]C-[::-60]R}};
\node[above right=of A] (B) 
  {\chemfig{*6((-!\Me)=(-!\Me)-(-!\Me)=(-!\Me)-(-!\Me)=(-!\Me)-)}
};
\node[below right=of A] (C)    
  {\chemfig{CH_3CH_2-[:-60,,3]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]C{(}CH_3{)}_3}};
\draw[-stealth] (A) -- ( $ (A.0)!0.5!(B.west|-A.0) $ ) |- (B.west) node[auto,pos=0.7] {i,j};
\draw[-stealth] (A) -- ( $ (A.0)!0.5!(C.west|-A.0) $ ) |- (C.west) node[auto,pos=0.7] {j};
\end{tikzpicture}

\end{document}

enter image description here

1
  • 1
    Thank you for the solution. I was thinking in exactly opposite direction - placing tikz code inside chemmove command. But your solution looks much better than my attempts.
    – lastpook
    Sep 9, 2013 at 14:27
5

You say »Semantically it is exactly opposite to \merge command« so lets define a command \fork that is the opposite of \merge. For this I patch the necessary commands with etoolbox's \patchcmd. The idea is simple: define a boolean switch \iffork and add arrow heads depending on the status. Then define \merge so it sets \forkfalse and \fork the same way but with \forktrue.

Here we go:

\documentclass{article}
\usepackage{chemfig}
\usepackage{etoolbox}

\makeatletter
\newif\iffork

\patchcmd\CF@merge@ii{-CF@full}{\iffork\else -CF@full\fi}{}{}%
% \CF@merge@iii needs to be patched twice:
\patchcmd\CF@merge@iii{>=0]}{>=0,\iffork CF@full-\fi]}{}{}%
\patchcmd\CF@merge@iii{>=0]}{>=0,\iffork CF@full-\fi]}{}{}%
\patchcmd\CF@schemestart@i
  {\let\merge\CF@merge}
  {%
    \def\merge{\forkfalse\CF@merge}%
    \def\fork{\forktrue\CF@merge}%
  }
  {}{}
\patchcmd\CF@schemestart@v{\merge}{\merge\fork}{}{}

\makeatother

\begin{document}

\schemestart
 a \arrow{0} b \arrow{0} c
 \merge{v}(c1)(c2)(c3)--() d
\schemestop

\bigskip

\schemestart
 a \arrow{0} b \arrow{0} c
 \fork{v}(c1)(c2)(c3)--() d
\schemestop

\end{document}

enter image description here

4
  • That's just brilliant!
    – lastpook
    Sep 9, 2013 at 17:25
  • After careful consideration I've decided to give back the answer to Gonsalo Medina, since his solution is better suited to my actual needs: I'd like to put labels near each arrow head and \merge doesn't allow it, so does this solution. Also some additional tweaking is needed to make your code to work in horisontal direction.
    – lastpook
    Sep 9, 2013 at 17:44
  • @lastpook well, since you didn't say that you need it in your question I didn't add anything. Indeed this would require some more work...
    – cgnieder
    Sep 9, 2013 at 18:08
  • nevertheless, I think that your approach is more elegant
    – lastpook
    Sep 9, 2013 at 18:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .