When I use chemfig in conjuction when \tikz[overlay,remember picture] the positioning does go in the correct position. I am using XeLaTeX and the yLaTeX class (see this link: https://github.com/HarveySheppard/yLaTeX). Here are a few examples of the error:

\setchemfig{cram width=3pt}
\tikz[overlay,remember picture]{
\draw[-] (-0.1,0.2) ..controls +(120:1) and +(60:1) .. (0.1,0.2);
\draw[-,fill=black!10] (-0.1,-0.2) ..controls +(-120:1) and +(-60:1) .. 
\node[fill=white,inner sep=0.1pt] at (B){{\fontfamily{cmr}\selectfont
\draw[-latex,shorten <=2pt] (F) ..controls +(90:1.7cm)and+(90:1cm)..
\tikz[overlay,remember picture]{
\draw[-latex,shorten <=2pt,densely dashed] ([yshift=9pt]cb.north) ..controls +(180:0.7) and +(-90:1).. +(-0.7,1) node[above,align=center] {\scriptsize coordinate \scriptsize covalent\\ \scriptsize bond};
\chemmove{\node[xshift=6pt] at (c2.north east) {$-$};}
\chemmove{\node[xshift=6pt] at (c3.north east) {$-$};}

Here is the output: enter image description here The dashed arrow that points to coordinate covalent bond should be from the vertical bond between the Boron (B) and fluorine (F) in the last compound.

Another example:

\setchemfig{cram width=3pt}
\begin{tikzpicture}[overlay,remember picture]
\node[below=3mm of A,fill=dullblue,draw,ellipse] (Acid1) {Acid};
\node[below=3mm of B,draw,ellipse] (Base1) {Base};
\node[below=3mm of C,fill=dullblue,draw,ellipse] (Base2) {Base};
\node[below=3mm of D,draw,ellipse] (Acid2) {Acid};
\draw[blue!50] (Acid1) -- ++ (0,-1.5) coordinate(aux) -| (Base2);
\draw (Base1) -- ++ (0,-2)  -| (Acid2);
\node[anchor=south,blue!50,fill=white,outer sep=1pt] at (aux-|Base1) {Conjugate pair};

The following is required in the preamble:


The code comes from one of my previous questions: How to typset/draw conjugate acids and bases. It produces the following output enter image description here The text comes from the rest of my document. I am more worried about the fact that the tikz ovals are not in the correct location and do not know how to solve this issue. Any help would be appreciated.

  • Have you compiled the documents at least twice in succession? This is necessary with overlays.
    – AndréC
    Dec 14 '18 at 6:20
  • Yes I have compiled it 3 times
    – sab hoque
    Dec 14 '18 at 6:22
  • 2
    While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. Dec 14 '18 at 6:30
  • 3
    The overlay/remember picture thing just doesn't work with other drivers than pdftex or luatex. I got similar unsatisfactory results with the Dvips route.
    – AlexG
    Dec 14 '18 at 10:44
  • 3
    @sabhoque It appears there is a workaround. There are two adjusts you need to make. First, replace \tikzmarknode with \subnode. Second, use the workaround definition within \makeatletter ... \makeatother from the answer in the link.
    – whatisit
    Dec 15 '18 at 5:12

As suggested by @whatisit adding the following code to the preamble makes the code render correctly:

        \special{pdf: content q}%
        \pgfsys@invoke{q -1 0 0 -1 0 0 cm}%
        \special{pdf: content -1 0 0 -1 0 0 cm q}% translate to original coordinate system
        \pgfsys@invoke{0 J [] 0 d}% reset line cap and dash
        \pgfsys@invoke{n Q Q Q}%

The code comes from 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.