5

So I want to make my chemical formulars in TikZ and I have this right now:

My problem is that I want to curve the yellow line below the molecule to make the text more visible and to not cut the molecule in the middle. I've read through the chemfig manual already and found the Curved bonds, but I don't quite understand the syntax and how to add another control point.

My other problem is that I want to add a floating text with a floating arrow that points to a specific atom.

At the end I want it to kinda look like this: (I have added another orange and purple line to show what kind of lines I want)

This is my code:

\documentclass[border=3mm]{standalone}

\usepackage{chemfig}

\setchemfig{debug=false}
\setchemfig{scheme debug=false}

\begin{document}
    \schemestart
        \subscheme{
            \chemfig{([::+90]C(-[::+135]H)(-[::+225]H)=C(-[::+45]H)(-[::+315]H))}
        }
        \+
        \chemfig{\charge{90=\|,180=\|,270=\|}{Br}-\charge{0=\|,90=\|,270=\|}{Br}}
        \arrow(.east--.west){<=>}
        \subscheme{
            \chemfig{([::+90]C(-[::+135]H)(-[::+225]H)=[@{a}]C(-[::+45]H)(-[::+315]H))}
        }
        \chemfig{@{b}\charge{90=\|,180=\|,270=\|,45[red,anchor=180+\chargeangle]=$\delta^+$}{Br}-[@{c}]@{d}\charge{0=\|,90=\|,270=\|,45[blue,anchor=180+\chargeangle]=$\delta^-$}{Br}}
        \arrow(@c2--)[-90]
        \chemfig{([::-90]C(-[::+90]H)(-[::+180]H)(-[::+270]\charge{90=\|,180=\|,270=\|}{Br})-C(-[::+0]H)(-[::+90]\charge{0=\|,90=\|,270=\|}{Br})(-[::+270]H))}
        \arrow(@c4--){<=>}[-90]
        \hflipnext
        \chemfig{\charge{180[red,circle,anchor=180+\chargeangle]=$\oplus$}{Br}(-[1,,,,dash pattern=on 2pt off 2pt]@{e}C?(-[::+0]H)(-[::+90]H))(-[7,,,,dash pattern=on 2pt off 2pt]C?(-[::+0]H)(-[::+270]H))}
        \quad
        \quad
        \chemfig{@{f}\charge{0=\|,90=\|,180=\|,270=\|,45[blue,circle,anchor=180+\chargeangle]=$\ominus$}{Br}}
        \arrow(@[email protected]){<=>}
    \schemestop
    \chemmove{
        \draw[red,shorten >=4pt] (a).. controls +(0:1cm) and +(225:1cm).. (b);
        \draw[red,shorten >=4pt] (c).. controls +(270:1cm) and +(270:1cm).. (d);
        \draw[orange,shorten >=4pt] (f).. controls +(255:1cm) and +(225:1cm).. node[below] {Rueckseitenangriff} (e);
    }
\end{document}

Help would be appreaciated, thanks!

3

2 Answers 2

3

Here are two options, and there's at least one more.

chemfig is built on Tikz, so you can use Tikz-commands, too. Which you did by

  • giving certain coordinates names (a) .. (f)
  • providing \draw pathes

Using controls is a way to specify Bezier curves in Tikz. I find the parameters hard to imagine, though if you can, it's a perfect way to create fancy curves.

However, I provide two alternatives:

        % ~~~ straight forward replacement ~~~~~~~~~~~~~
        \draw[orange,shorten >=4pt] 
                    (f) -- ++(0,-1.7) 
                        -- node[pos=.5,below]{Rückseitenangriff} ++(-3.5,0)
                        --  (e);
  • \draw from (f) -- (e)
  • but before ending this path by ;
  • place two new coordinates (++) for the down- and side-steps, described as relative steps
  • put a node at the lower new path (watch the missing \) // use pos= for furter fine tuning
  • no fancy curving, just draw as specified
        % ~~~ an alternative ~~~~~~~~~~~~~~~~~~~~~~~
        \draw[green,shorten >=4pt,rounded corners] 
                    (f.230) -- ++(0,-1.5) 
                        --  ++(-3.2,0)
                        --  (e);
  • same idea
  • left out the node, as the drawing won't expand for some reason
  • used rounded corners option from Tikz
  • shifted the starting point a bit to the left, using polar coordinates (f.230)

You could also replace all or some of the -- statements by to[in=,out=], like so:

(f.230) to[out=300,in=45] ++(0,-1.5) ...

to start with a bow (hopefully) to the right.

As you can also see I put the language package babel for convenience.

result

\documentclass[border=3mm]{standalone}
\usepackage[ngerman]{babel}     % <<<
\usepackage{chemfig}

%\setchemfig{debug=false}
%\setchemfig{scheme debug=false}

\begin{document}
    \schemestart
        \subscheme{
            \chemfig{([::+90]C(-[::+135]H)(-[::+225]H)=C(-[::+45]H)(-[::+315]H))}
        }
        \+
        \chemfig{\charge{90=\|,180=\|,270=\|}{Br}-\charge{0=\|,90=\|,270=\|}{Br}}
        \arrow(.east--.west){<=>}
        \subscheme{
            \chemfig{([::+90]C(-[::+135]H)(-[::+225]H)=[@{a}]C(-[::+45]H)(-[::+315]H))}
        }
        \chemfig{@{b}\charge{90=\|,180=\|,270=\|,45[red,anchor=180+\chargeangle]=$\delta^+$}{Br}-[@{c}]@{d}\charge{0=\|,90=\|,270=\|,45[blue,anchor=180+\chargeangle]=$\delta^-$}{Br}}
        \arrow(@c2--)[-90]
        \chemfig{([::-90]C(-[::+90]H)(-[::+180]H)(-[::+270]\charge{90=\|,180=\|,270=\|}{Br})-C(-[::+0]H)(-[::+90]\charge{0=\|,90=\|,270=\|}{Br})(-[::+270]H))}
        \arrow(@c4--){<=>}[-90]
        \hflipnext
        \chemfig{\charge{180[red,circle,anchor=180+\chargeangle]=$\oplus$}{Br}(-[1,,,,dash pattern=on 2pt off 2pt]@{e}C?(-[::+0]H)(-[::+90]H))(-[7,,,,dash pattern=on 2pt off 2pt]C?(-[::+0]H)(-[::+270]H))}
        \quad
        \quad
        \chemfig{@{f}\charge{0=\|,90=\|,180=\|,270=\|,45[blue,circle,anchor=180+\chargeangle]=$\ominus$}{Br}}
        \arrow(@[email protected]){<=>}
    \schemestop
    \chemmove{
        \draw[red,shorten >=4pt] (a).. controls +(0:1cm) and +(225:1cm).. (b);
        \draw[red,shorten >=4pt] (c).. controls +(270:1cm) and +(270:1cm).. (d);
%        \draw[orange,shorten >=4pt] (f).. controls +(255:1cm) and +(225:1cm).. node[below] {Rueckseitenangriff} (e);
        % ~~~ straight forward replacement ~~~~~~~~~~~~~
        \draw[orange,shorten >=4pt] 
                    (f) -- ++(0,-1.7) 
                        -- node[pos=.5,below]{Rückseitenangriff} ++(-3.5,0)
                        --  (e);
        % ~~~ an alternative ~~~~~~~~~~~~~~~~~~~~~~~
        \draw[green,shorten >=4pt,rounded corners] 
                    (f.230) -- ++(0,-1.5) 
                        --  ++(-3.2,0)
                        --  (e);
    }
\end{document}
3

Another approach

\documentclass[border={5mm 12mm 5mm 5mm}]{standalone}
\usepackage{chemfig}
\tikzset{mybond/.style={dash pattern=on 2pt off 2pt}}
\begin{document}
\schemestart
\chemfig{C(-[5]H)(-[7]H)=[2]C(-[1]H)(-[3]H)}
\arrow{0}[,0]
\+
\chemfig{\charge{90=\|,180=\|,270=\|}{Br}-\charge{0=\|,90=\|,270=\|}{Br}}
\arrow{<=>}
\chemfig{C(-[5]H)(-[7]H)=[@{a}2]C(-[1]H)(-[3]H)}
\arrow{0}[,0.2]
\chemfig{@{b}\charge{90=\|,180=\|,270=\|,45[red,anchor=180+\chargeangle]=$\delta^+$}{Br}-[@{c}]@{d}\charge{0=\|,90=\|,270=\|,45[blue,anchor=180+\chargeangle]=$\delta^-$}{Br}}
\arrow(@c3--){<=>}[-90]
\arrow(@c1--)[-90]
\chemfig{H-[2]C(-\charge{0=\|,90=\|,270=\|}{Br})(-[4]H)-[2]C(-H)(-[4]\charge{90=\|,180=\|,270=\|}{Br})-[2]H}
\arrow{<=>}[,2.03]
\chemfig{C?[db1](-[5]H)(-[7]H)(-[2,0.75,,,draw=none]-[,0.8,,,draw=none]@{g}\charge{180[red,circle,anchor=180+\chargeangle]=$\oplus$}{Br}?[db1,,mybond]?[db2]-[,,,,draw=none]@{f}\charge{0=\|,90=\|,180=\|,270=\|,45[blue,circle,anchor=180+\chargeangle]=$\ominus$}{Br})-[2,1.5]@{e}C?[db2,,mybond](-[1]H)(-[3]H)}
\schemestop
\chemmove{%
    \draw[red, shorten >=4pt] (a) .. controls +(0:8mm) and +(225:12mm).. (b);
    \draw[red, shorten >=4pt] (c) .. controls +(270:1cm) and +(270:1cm).. (d);
    \draw[orange, shorten >=4pt, shorten <=4pt] (f) .. controls +(255:3.5cm) and +(225:4cm).. (e) node[pos=0.35, below=1pt] {Rueckseitenangriff};
    \draw[<-, shorten <=4pt, blue] (g) -- ++(60:1) node[above] {Text};
}
\end{document}

enter image description here

You must log in to answer this question.

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