I want to color simple functional groups in organic molecules using the chemfig
package. I've come up with a solution that achieves what I want (MWE), but I find it very cumbersome. I thought it could be possible to wrap an entire group in one single color
-statement. This question about colouring the background of a group of atoms in chemfig
also gives a neat graphical emphasis of a group of atoms.
Is my solution, and the solution to the question above, the easiest way to colour or mark groups of atoms (including bonds) in chemfig
? Just now, I don't have a need to easily reproduce loads of coloured functional groups, but I would like to know if there are easier ways to solve this problem without predefining macros for each group.
I believe I understand that the underlying problem is the way chemfig
uses TikZ nodes to draw the structures, but I can't help to think that there should be a way to define some color environment that applies to all the TikZ nodes made by chemfig
.
MWE:
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-{\color{blue}C}(=[1,,,,blue] {\color{blue}O})(-[7,,,,blue] {\color{blue}OH})}
\end{document}
Producing