# Forked arrows with chemfig

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:

-

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}


-
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 '13 at 14:27

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}


-
That's just brilliant! –  lastpook Sep 9 '13 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 '13 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... –  clemens Sep 9 '13 at 18:08
nevertheless, I think that your approach is more elegant –  lastpook Sep 9 '13 at 18:16
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.9530982375144958, "perplexity": 3908.349445366344}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2015-11/segments/1424936463104.7/warc/CC-MAIN-20150226074103-00246-ip-10-28-5-156.ec2.internal.warc.gz"}