8

I have the following chemical reaction scheme with a shaded polygon (using link) as shown in MWE below:

MWE

\documentclass{article}
\usepackage{chemfig}

\begin{document}
%\schemedebug{true} % uncomment to see node names
\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
%
\chemmove{%
  \draw [red,fill=red,fill opacity=0.5,thick] ([shift={(-5pt,1em)}]Q.north west) -- ([yshift=1em]S.north) --
                    ([yshift=1em]T.north) -- ([shift={(5pt,1em)}]U.north east) --
                    ([shift={(5pt,-1.5em)}]U.south east) --
                    ([yshift=-1.5em]T.south) -- ([yshift=-2em]R.south) --
                    ([shift={(-5pt,-2em)}]Q.south west) -- cycle;
}
\schemestop
\end{document}

However, the shaded polygon is overlaid on the reaction scheme as shown in the figure. How do I move back the shaded polygon to the back of the reaction scheme? I need the reaction scheme placed on the shaded polygon. Can this be done?

enter image description here

8

You could put it on a background layer, but why bother? Does it matter if it is behind? Or only that it looks as if it is behind? If the latter, what about the following?

looks behind?

\documentclass{article}
\usepackage{chemfig}

\begin{document}
%\schemedebug{true} % uncomment to see node names
\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
%
\chemmove{%
  \draw [red,fill=red,fill opacity=0.5,blend mode=multiply,thick] ([shift={(-5pt,1em)}]Q.north west) -- ([yshift=1em]S.north) --
                    ([yshift=1em]T.north) -- ([shift={(5pt,1em)}]U.north east) --
                    ([shift={(5pt,-1.5em)}]U.south east) --
                    ([yshift=-1.5em]T.south) -- ([yshift=-2em]R.south) --
                    ([shift={(-5pt,-2em)}]Q.south west) -- cycle;
}
\schemestop
\end{document}
  • Very nice all your works. +1 everybody. – Sebastiano Feb 7 '18 at 9:59
6

Just in case you really want it behind, there is always the eso-pic rescue.

\documentclass{article}
\usepackage{chemfig}
\usepackage{eso-pic}

\begin{document}
%\schemedebug{true} % uncomment to see node names
\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
%
% \chemmove{%
% }
\schemestop
\AddToShipoutPictureBG*{
\tikz[overlay,remember picture]{
  \draw [red,fill=red,opacity=0.5,thick,semitransparent] ([shift={(-5pt,1em)}]Q.north west) -- ([yshift=1em]S.north) --
                    ([yshift=1em]T.north) -- ([shift={(5pt,1em)}]U.north east) --
                    ([shift={(5pt,-1.5em)}]U.south east) --
                    ([yshift=-1.5em]T.south) -- ([yshift=-2em]R.south) --
                    ([shift={(-5pt,-2em)}]Q.south west) -- cycle;
}
}
\end{document}

enter image description here

For the example at hand, @cfr's solution is probably simpler, but if the foreground has colors, this method might be considered.

  • Wouldn't it be simpler to use on background layer with the relevant TikZ library? Or doesn't that work here? (I didn't try it.) – cfr Feb 7 '18 at 16:35
  • @cfr It does not work, at least not without modifying the chemfig package. – user121799 Feb 7 '18 at 16:37
  • I guess because it draws everything in separate tikzpictures :(. – cfr Feb 7 '18 at 23:31
  • @cfr I tried playing with these layers for quite a while, but inside the \schemestart ... \schemestop TikZ commands do not work, and afterwards it's too late. Yet chemfig is kind enough to remember its pictures. In the end I gave up and went for the brutal eso-pic option. As I said, this makes real sense only if you use colors (including white) that are not to be shaded. Of course, there might be a sneaky every picture option, but I did not manage to find any. – user121799 Feb 8 '18 at 0:14
  • I looked at the code for \chemmove and that's why I said it is starting new tikzpictures. So you can't go behind what's already typeset, regardless if you remember it or not. – cfr Feb 8 '18 at 0:25

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.