8

I have just discovered the TikZ spin-off chemfig package for chemistry drawings. I just wanted to add some transparent box to highlight a certain region of the drawn molecule with some text using relative nodes with TikZ. The relativity is needed so that to keep everything in one piece when rotated. For this reason the molecule was drawn with relative angles instead of absolute ones. Another request, is how can I put large brackets instead of the shaded box idea, I mean just to put the shaded area in between two large brackets?
What I want looks like this image below:

enter image description here

Code for chemfig:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{chemfig}
\begin{document}
\setatomsep{2em}

\chemfig{[:-30]*5(-(=O)-N(-O-[::60]([::-60]--[::60]--[::60]--[::60]-(=[::-60]O)-[::60]O-#(,7pt)[::-60]*5(N-(=O)---(=O)-#(0,5pt)) )=[::60]O)-(=O)--)}

\end{document}
13

This is not fully automatic (you need to specify the rotation for the molecule and the corresponding \chemmove command) and the TikZ code can most likely be improved but it may be a start. It places two invisible bonds where I've marked the respective ends with chemfigs @{<node name>} syntax. They are used to draw the rectangle later.

enter image description here

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{chemfig}

\begin{document}
\setatomsep{2em}

\chemfig{
  [:-30]*5(
    -(=O)-N(
      -O(-[::110,2,,,draw=none]@{a})
      -[::60](
        [::-60]--[::60]--[::60]--[::60]
        -(=[::-60]O)(-[::-50,2,,,draw=none]@{b})
        -[::60]O-#(,7pt)[::-60]
        *5(N-(=O)---(=O)-#(0,5pt))
      )=[::60]O
    )-(=O)--
  )
}
\chemmove[orientation/.style={rotate=0}]{
  \draw[orientation,draw=black,opacity=.2,fill=black!30]
    (a) -| (b) -| (a)
    node[pos=.25,above,opacity=1,orientation]{Some text here} ;
}

\chemfig{
  [:0]*5(
    -(=O)-N(
      -O(-[::110,2,,,draw=none]@{a})
      -[::60](
        [::-60]--[::60]--[::60]--[::60]
        -(=[::-60]O)(-[::-50,2,,,draw=none]@{b})
        -[::60]O-#(,7pt)[::-60]
        *5(N-(=O)---(=O)-#(0,5pt))
      )=[::60]O
    )-(=O)--
  )
}
\chemmove[orientation/.style={rotate=30}]{
  \draw[orientation,draw=black,opacity=.2,fill=black!30]
    (a) -| (b) -| (a)
    node[pos=.25,above,opacity=1,orientation]{Some text here} ;
}

\chemfig{
  [:-60]*5(
    -(=O)-N(
      -O(-[::110,2,,,draw=none]@{a})
      -[::60](
        [::-60]--[::60]--[::60]--[::60]
        -(=[::-60]O)(-[::-50,2,,,draw=none]@{b})
        -[::60]O-#(,7pt)[::-60]
        *5(N-(=O)---(=O)-#(0,5pt))
      )=[::60]O
    )-(=O)--
  )
}
\chemmove[orientation/.style={rotate=-30}]{
  \draw[orientation,draw=black,opacity=.2,fill=black!30]
    (a) -| (b) -| (a)
    node[pos=.25,above,opacity=1,orientation]{Some text here} ;
}

\end{document}

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.