3

I have the following reaction scheme in chemfig:

enter image description here

I need for some of the reversible reactions: forward reactions arrow in black and the backward reactions arrow in red. Is it possible in chemfig?

MWE

\documentclass{article}
\usepackage{chemfig}

\begin{document}

\schemestart
P \arrow(P--Q){<=>[$\mathrm{k_{pq}}$]}[,,,red] Q
\arrow{<=>[$\mathrm{k_{qs}}$]}[30,,,red] S \arrow(S--T){<=>[][$\mathrm{k_{st}}$]}[-30,,,red] T
\arrow(@Q--R){<=>[][$\mathrm{k_{qr}}$]}[-30,,,red] R
\arrow(@R--@T){<=>[][$\mathrm{k_{rt}}$]}[,,,red]
\arrow(@T--U){<=>[][$\mathrm{k_{tu}}$]}[,,,red] U
\arrow(@U--V){->[$\mathrm{k_{uv}}$]} V
\schemestop

\end{document}

1 Answer 1

4

As requested in the comments, here is a possible solution, that does not overwrite the definition of <=>, but rather defines its own new arrow <=r>.

\documentclass{article}
\usepackage{chemfig}

\catcode`\_=11
\definearrow3{<=r>}{%
    \CF_arrowshiftnodes{#3}%
    \path[allow upside down](\CF_arrowstartnode)--(\CF_arrowendnode)%
            node[pos=0,sloped,yshift=1pt](\CF_arrowstartnode u0){}%
            node[pos=0,sloped,yshift=-1pt](\CF_arrowstartnode d0){}%
            node[pos=1,sloped,yshift=1pt](\CF_arrowstartnode u1){}%
            node[pos=1,sloped,yshift=-1pt](\CF_arrowstartnode d1){};%
    \begingroup
        \pgfarrowharpoontrue
        \expandafter\draw\expandafter[\CF_arrowcurrentstyle](\CF_arrowstartnode u0)--(\CF_arrowstartnode u1);%
        \expandafter\draw\expandafter[\CF_arrowcurrentstyle,red](\CF_arrowstartnode d1)--(\CF_arrowstartnode d0);%
    \endgroup
    \CF_arrowdisplaylabel{#1}{0.5}+\CF_arrowstartnode{#2}{0.5}-\CF_arrowendnode%
}
\catcode`\_=8

\begin{document}

\schemestart
P \arrow(P--Q){<=r>[$\mathrm{k_{pq}}$]}[,,,] Q
\arrow{<=>[$\mathrm{k_{qs}}$]}[30,,,] S \arrow(S--T){<=>[][$\mathrm{k_{st}}$]}[-30,,,] T
\arrow(@Q--R){<=>[][$\mathrm{k_{qr}}$]}[-30,,,] R
\arrow(@R--@T){<=>[][$\mathrm{k_{rt}}$]}[,,,]
\arrow(@T--U){<=>[][$\mathrm{k_{tu}}$]}[,,,] U
\arrow(@U--V){->[$\mathrm{k_{uv}}$]} V
\schemestop

\end{document}

This results in the following output:

enter image description here

The following code applies the color change to all <=> arrows.

\documentclass{article}
\usepackage{chemfig}

\catcode`\_=11
\definearrow3{<=>}{%
    \CF_arrowshiftnodes{#3}%
    \path[allow upside down](\CF_arrowstartnode)--(\CF_arrowendnode)%
            node[pos=0,sloped,yshift=1pt](\CF_arrowstartnode u0){}%
            node[pos=0,sloped,yshift=-1pt](\CF_arrowstartnode d0){}%
            node[pos=1,sloped,yshift=1pt](\CF_arrowstartnode u1){}%
            node[pos=1,sloped,yshift=-1pt](\CF_arrowstartnode d1){};%
    \begingroup
        \pgfarrowharpoontrue
        \expandafter\draw\expandafter[\CF_arrowcurrentstyle](\CF_arrowstartnode u0)--(\CF_arrowstartnode u1);%
        \expandafter\draw\expandafter[\CF_arrowcurrentstyle,red](\CF_arrowstartnode d1)--(\CF_arrowstartnode d0);% <---------------modified line
    \endgroup
    \CF_arrowdisplaylabel{#1}{0.5}+\CF_arrowstartnode{#2}{0.5}-\CF_arrowendnode%
}
\catcode`\_=8

\begin{document}

\schemestart
P \arrow(P--Q){<=>[$\mathrm{k_{pq}}$]}[,,,] Q
\arrow{<=>[$\mathrm{k_{qs}}$]}[30,,,] S \arrow(S--T){<=>[][$\mathrm{k_{st}}$]}[-30,,,] T
\arrow(@Q--R){<=>[][$\mathrm{k_{qr}}$]}[-30,,,] R
\arrow(@R--@T){<=>[][$\mathrm{k_{rt}}$]}[,,,]
\arrow(@T--U){<=>[][$\mathrm{k_{tu}}$]}[,,,] U
\arrow(@U--V){->[$\mathrm{k_{uv}}$]} V
\schemestop

\end{document}

I have copied the definition of <=> from chemfig.tex and added ,red in the marked line in the code.

This results in the following output:

enter image description here


A previous version of these MWEs which work with older versions of the chemfig package (prior to v 1.4) can be accessed through the revision history of this post.

8
  • I had to modify the question. I need it for only some reactions; not all reactions.
    – nxkryptor
    Dec 11, 2017 at 17:07
  • 1
    @nxkryptor: I have updated my answer according to your request.
    – leandriis
    Dec 11, 2017 at 18:38
  • The color changes, however the harpoon arrows are missing and I get the following error: ! Undefined control sequence. \<=r> ... @d1){};\begingroup \pgfarrowharpoontrue \expandafter \draw \expand... l.24 P \arrow(P--Q){<=r>[$\mathrm{k_{pq}}$]}[,,,]
    – nxkryptor
    Dec 12, 2017 at 11:01
  • @nxkryptor: I have tried to reproduce the error you described by using the above MWE, but unfortunately I was not able to. Did you make sure, there are no typos in the code?
    – leandriis
    Dec 12, 2017 at 21:54
  • I check for typos; everything looks fine. The interesting thing is if I comment \pgfarrowharpoontrue, the error no longer exists. However, the harpoon arrows are missing.
    – nxkryptor
    Dec 13, 2017 at 7:10

You must log in to answer this question.

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