I want to fill the background of some functional groups or atoms including bonds to emphasize them. For instance, to emphasize carbonyl group in a keton, fill the background of C=O like:

enter image description here

I'm using chemfig to draw chemistry equations, and I have a workaround which cover with overlay(chemmove):

    \node[fill=purple!20,anchor=text,inner sep=0.1em]
        at (kc.text) {\chemfig{C(=[:90]O)}};

However, I need simpler and smarter way since, in this way, I have to write the same code twice(which could be very long if the atoms and bonds are long and complicated) and it does not work with wrong anchoring from time to time.


You could mark two nodes with the @{<name>} syntax and then draw a rectangle with fill opacity=.2 (or whatever suits you best):

    fill opacity=.2,
    rounded corners=2pt
    ([xshift=-3pt,yshift=-1pt]C.south west)
    ([xshift=3pt,yshift=3pt]O.north east) ;


| improve this answer | |
  • This looks nice but it's another workaround, isn't it? Because the filled rectangle is laid over C=O, the fill opacity value shoulde be small otherwise it will paint out the below drawings. Although I think this is simple and very helpful, I want to wait for more general solution which does not cover the drawings. Thank you! – xylosper Jul 14 '13 at 15:04
  • “[...] it's another workaround, isn't it? ” - Well, that may be, but at least it saves you the trouble of typing the concerned molecule part twice :) – cgnieder Jul 14 '13 at 21:48
  • Yes, I agree with you. It is definitely better and I couldn't find any other solution. Thanks. – xylosper Jul 15 '13 at 1:00

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.