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}
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}

\makeatletter
\definearrow3{<=r>}{%
    \CF@arrow@shift@nodes{#3}%
    \path[allow upside down](\CF@arrow@start@node)--(\CF@arrow@end@node)%
            node[pos=0,sloped,yshift=1pt](\CF@arrow@start@node @u0){}%
            node[pos=0,sloped,yshift=-1pt](\CF@arrow@start@node @d0){}%
            node[pos=1,sloped,yshift=1pt](\CF@arrow@start@node @u1){}%
            node[pos=1,sloped,yshift=-1pt](\CF@arrow@start@node @d1){};%
    \begingroup
        \pgfarrowharpoontrue
        \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node @u0)--(\CF@arrow@start@node @u1);%
        \expandafter\draw\expandafter[\CF@arrow@current@style,red](\CF@arrow@start@node @d1)--(\CF@arrow@start@node @d0);%
    \endgroup
    \CF@arrow@display@label{#1}{0.5}+\CF@arrow@start@node{#2}{0.5}-\CF@arrow@end@node%
}
\makeatother

\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}

\makeatletter
\definearrow3{<=>}{%
    \CF@arrow@shift@nodes{#3}%
    \path[allow upside down](\CF@arrow@start@node)--(\CF@arrow@end@node)%
            node[pos=0,sloped,yshift=1pt](\CF@arrow@start@node @u0){}%
            node[pos=0,sloped,yshift=-1pt](\CF@arrow@start@node @d0){}%
            node[pos=1,sloped,yshift=1pt](\CF@arrow@start@node @u1){}%
            node[pos=1,sloped,yshift=-1pt](\CF@arrow@start@node @d1){};%
    \begingroup
        \pgfarrowharpoontrue
        \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node @u0)--(\CF@arrow@start@node @u1);%
        \expandafter\draw\expandafter[\CF@arrow@current@style,red](\CF@arrow@start@node @d1)--(\CF@arrow@start@node @d0);% <---------------modified line
    \endgroup
    \CF@arrow@display@label{#1}{0.5}+\CF@arrow@start@node{#2}{0.5}-\CF@arrow@end@node%
}
\makeatother

\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

  • I had to modify the question. I need it for only some reactions; not all reactions. – nxkryptor Dec 11 '17 at 17:07
  • 1
    @nxkryptor: I have updated my answer according to your request. – leandriis Dec 11 '17 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 '17 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 '17 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 '17 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.