I have a lot of molecules to draw.
For teaching purposes I need to color certain atoms or group of atoms.
Due to alignment of the main chain, I'm using a |
symbol after each atom on group, combined with textcolor
, to change color them, the same way as used by unbonpetit.
But actually this is tedious, and I would like a more easy/simple/short mode to do that.
That is my code:
\documentclass{article}
\usepackage{chemfig}
\usetikzlibrary{decorations.pathreplacing}
\tikzset{brace/.style = { decorate, decoration={brace, amplitude=5pt} }}
\setchemfig{%
atom sep=17pt,
bond offset=1pt
}
\newcommand{\blue}[1]{\textcolor{blue}{#1}}
\newcommand{\red}[1]{\textcolor{red}{#1}}
\begin{document}
\schemestart
\chemfig{%
[:-90]CH_2OH
-[@{bond1},,1,3]\blue{H}|\blue{O}|\blue{C}|\blue{H}
-[,,3,2]\blue{H}|\blue{C}|\blue{O}|\blue{H}
-[,,2,3]\blue{H}|\blue{O}|\blue{C}|\blue{H}
-[,,3]C(=[::90]O)
-[,,1,3]\blue{H}|\blue{O}|\blue{C}|\blue{H}
-[@{bond2},,3,3]\red{H}|\red{O}|\red{C}|\red{H}
-[,,3,3]\red{H}|\red{O}|\red{C}|\red{H}
-[@{bond3},,3,1]CH_2OH
}
%
\schemestop
\chemmove{
\draw[-,brace]
([xshift=30pt, yshift=-1pt]bond1) --
([xshift=30pt, yshift= 1pt]bond2)
node[midway, right=5pt]{\blue{\textsc{l}-\textit{gluco}-}};
%
\draw[-,brace]
([xshift=30pt, yshift=0]bond2) --
([xshift=30pt, yshift=0]bond3)
node[midway, right=5pt]{\red{\textsc{l}-\textit{erythro}-}};
}
\end{document}
I would appreciate any help!