3

How does one put a box around a group of atoms?

For example, I'm looking to put a box around the hydroxyl group with its bond (--OH) in the following molecule and can't seem to get any luck with the documentation or fbox. Any ideas?

\chemfig{C(-[2]H)(-[4]H)(-[6]H)-C(-[2]H)(-[6]H)-OH}
5

TikZ masters surely can do this better but a basic idea is this: use chemfig's @{node name} syntax for marking nodes and draw the rectangle afterwards using the specified nodes:

\documentclass{article}
\usepackage{chemfig}
\begin{document}

\chemfig{C(-[2]H)(-[4]H)(-[6]H)-C(-[2]H)(-[6]H)-[@{b1,0}]O@{H}H}
\chemmove{
  \draw[-,red]
    (b1) -- ++(0,.25) -| (H.east)
    (b1) -- ++(0,-.25) -| (H.east) ;
}

\end{document}

enter image description here

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.