LaTeX forum ⇒ Math & Sciencechemfig | Custom Arrows in Reaction Schemes Topic is solved

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
niteshs
Posts: 45
Joined: Wed Jun 06, 2012 9:57 pm

chemfig | Custom Arrows in Reaction Schemes

Postby niteshs » Fri Sep 07, 2012 5:39 am

Hi,

I am trying to produce a reaction scheme with curved arrows as shown in this example (the structures are purely for example):
react1.png
react1.png (8.41 KiB) Viewed 10287 times

I have been able to create the basic scheme with the following code:
\documentclass{article}
\usepackage{chemfig}
\begin{document}
%\schemedebug{true}
\schemestart
\tiny\chemname{\chemfig{*6(-=-(-R2)=-*6(-(-R1)=-(-*5(-----))--)=)}}{\small Some structure}
\arrow(.-10--){->[Text]}[,3]
\tiny\chemname{\chemfig{*6(=-*6(-=-=-)=-=-)}}{\small Another structure}
\arrow{0}[,0.5]
+\arrow{0}[,0.5]
\tiny\chemname{\chemfig{[:20]*5(-----)}}{\small And another}
\schemestop
\end{document}

which produces the following result:
react2.png
react2.png (3.79 KiB) Viewed 10287 times

I don't know how to add the curved arrows.
Can someone help me with this please?
Last edited by niteshs on Fri Sep 07, 2012 5:42 am, edited 1 time in total.

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net
LaTeX Beginner's Guide LaTeX Cookbook
niteshs
Posts: 45
Joined: Wed Jun 06, 2012 9:57 pm

chemfig | Custom Arrows in Reaction Schemes

Postby niteshs » Fri Sep 07, 2012 5:41 am

I guess I could have made the MWE much more simpler as follows:
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\schemestart
A\arrow{->[Text]}[,3]
B\arrow{0}[,0.5]+\arrow{0}[,0.5]
C
\schemestop
\end{document}

User avatar
cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm

chemfig | Custom Arrows in Reaction Schemes  Topic is solved

Postby cgnieder » Fri Sep 07, 2012 5:45 pm

The following is a quick solution so I guess there are probably better ones. ChemFig provides the command \definearrow and some others (see section 10 of part V in the manual). The code below adapts the definition of the -U> arrow made by ChemFig:

\documentclass{article}
\usepackage{chemfig}

\makeatletter
\definearrow5{-n>}{% #4=coeff du rayon de l'arc de cercle  #5=1/2 angle
	\CF@arrow@shift@nodes{#3}%
	\expandafter\draw\expandafter[\CF@arrow@current@style,-CF@full](\CF@arrow@start@node)--(\CF@arrow@end@node)node[pos=.2](narrow@arctangent@i){} node[pos=.5](narrow@arctangent@ii){};%
	\edef\CF@tmp@str{[\ifx\@empty#1\@empty draw=none,\fi-CF@full]}%
	\expandafter\draw\CF@tmp@str (narrow@arctangent@i)%
		arc[radius=\CF@compound@sep*\CF@current@arrow@length*\ifx\@empty#4\@empty0.333\else#4\fi,start angle=\CF@arrow@current@angle+90,%
		delta angle=-\ifx\@empty#5\@empty60\else#5\fi]node(narrow@start){};
	\edef\CF@tmp@str{[\ifx\@empty#2\@empty draw=none,\fi-CF@full]}%
	\expandafter\draw\CF@tmp@str (narrow@arctangent@ii)%
		arc[radius=\CF@compound@sep*\CF@current@arrow@length*\ifx\@empty#4\@empty0.333\else#4\fi,start angle=\CF@arrow@current@angle+90,%
		delta angle=-\ifx\@empty#5\@empty60\else#5\fi]node(narrow@end){};
	\edef\CF@tmp@str{\if\string-\expandafter\@car\detokenize{#4.}\@nil+\else-\fi}%
	\CF@arrow@display@label{#1}{0}\CF@tmp@str{narrow@start}{#2}{1}\CF@tmp@str{narrow@end}%
}
\makeatother

\begin{document}

\schemestart
A \arrow{-n>[1][2]}[,2] B
\schemestop

\schemestart
\subscheme{A \arrow{-n>[1][2]}[,2] B}
\arrow{0}[90,0]text
\schemestop

\schemestart
A \arrow{-n>[*01][*02]}[-90,2] B
\schemestop

\end{document}


customarrow.png
customarrow.png (7.88 KiB) Viewed 10277 times


Regards
site moderator & package author

niteshs
Posts: 45
Joined: Wed Jun 06, 2012 9:57 pm

Re: chemfig | Custom Arrows in Reaction Schemes

Postby niteshs » Fri Sep 07, 2012 8:31 pm

Excellent! Thank you cgnieder!


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 10 guests