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 am defining a submolecule in chemfig (2,2'-bipyridine) and I want to show the lone pair of electrons on both the Nitrogens. (For those who care, I wish to show a coordination bond between the lone pairs and a metal but that's the next question!)

I have defined the submolecule and when I display it rotated the positioning of the lone pairs does not rotate as the \lewis command uses absolute positions rather than relative positions.

Is it possible to have relative lewis positions which can allow for rotation of the full molecule? (I attach nodes to the Ns so I can draw dative bonds from them at a later stage...)

MWE below...

\documentclass{article}
\usepackage{chemfig}


\definesubmol{bipy}{*6(-=-(-*6(-=-=-@{datN1}\lewis{3:,N}=))=@{datN2}\lewis{2:,N}-=)}


\begin{document}



\chemfig{!{bipy}}

\vspace{1cm}%just for clarity
\chemfig{[:60]!{bipy}}\\
Should have the lone pair of electrons on the lower N in position 4 and on the upper N in position 5 according to   \verb|\lewis{}| command in chemfig
\end{document}

bipy molecule enter image description here

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Here is an imperfect idea. The current angle of the arriving bond at an atom is available through \CF@current@angle. The proposal below uses it to compute the position of the lone pair.

\documentclass{article}
\usepackage{chemfig}

% this is far from perfect, the most obvious restriction is that it only allows
% to place _one_ electron pair.
\makeatletter
\def\rellewis@stripdecimals#1.#2\q@stop{#1}
\def\rellewis#1{\rel@lewis#1\q@stop}
\def\rel@lewis#1#2,#3\q@stop{%
  \pgfmathparse{mod(#1+round(\CF@current@angle/45),8)}%
  \edef\rellewis@pos{\expandafter\rellewis@stripdecimals\pgfmathresult\q@stop}%
  \expandafter\lewis\expandafter{\rellewis@pos#2,#3}%
}
\makeatother

\definesubmol{bipy}{*6(-=-(-*6(-=-=-\rellewis{6:,N}=))=\rellewis{7:,N}-=)}

\begin{document}

\chemfig{!{bipy}}
\quad
\chemfig{[:60]!{bipy}}
\quad
\chemfig{[:-30]!{bipy}}

\chemfig{[:90]!{bipy}}
\quad
\chemfig{[:-90]!{bipy}}
\quad
\chemfig{[:45]!{bipy}}
\end{document}

enter image description here

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.