Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

1 Answer 1

up vote 12 down vote accepted

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}
share|improve this answer

Your Answer

 
discard

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.