TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Welcome to TeX.sx! – clemens Jul 14 '13 at 12:47
@cgnieder Thanks! – xylosper Jul 14 '13 at 15:05
up vote 4 down vote accepted

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) ;


share|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 :) – clemens 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 posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.