1

What is the right way to color a submolecule defined by \definesubmol?

MWE

\documentclass[12pt]{article}
\usepackage{float}
\usepackage{chemfig}
\usepackage{chemmacros}
    \chemsetup{
        modules = all,
    }
\begin{document}
\begin{figure}[H]
\centering
\definesubmol{pvc}{CH_2-CH(-[:90]Cl)}
\chemfig{-!{pvc}- \color{green}{!{pvc}} -!{pvc}-}
\end{figure}
\end{document}

enter image description here

1 Answer 1

2

Answer based on a post that is here

\documentclass[12pt]{article}
\usepackage{float}
\usepackage{chemfig}
\usepackage{chemmacros}
\chemsetup{
    modules = all,
}

    \begin{document}
    \def\GREEN{\gdef\printatom##1{\color{green}\ensuremath{\mathrm{##1}}}}
    \def\BLACK{\gdef\printatom##1{\color{black}\ensuremath{\mathrm{##1}}}}
    \begin{figure}[H]
        \centering
        \definesubmol{pvc}{CH_2-CH(-[:90]Cl)}
        \chemfig{-!{pvc}(-[,,,,draw=none]\GREEN)([,,,,green]-!{pvc}-)\BLACK!{pvc}-}
    \end{figure}
\end{document}

enter image description here

You must log in to answer this question.

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