# \tikzexternalize and chemfig

First time posting here, and my english isn't that good but i'll try to explain my problem the best I can. I'm trying to externalize a figure, that was built using chemfig. Now the problem is that when I use \tikzexternalize it changes the position all the arrows of the fig. and it crops part of the figure. The figure is a description of electron movements of a molecule.

This is what I get without \tikzexternalize (the way i'm looking for after externalize)

This is what I get when I use \tikzexternalize

This is the code i'm using:

\documentclass[letterpaper,12pt]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish,es-noquoting]{babel}
\usepackage{tikz}
\usepackage{chemfig}
\usepackage{chemmacros}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{external}
%\tikzexternalize[prefix=tikz/]
\newcommand\namebond[4][3pt]{\chemmove{\path(#2)--(#3)node[midway,sloped,yshift=#1]{#4};}}
\newcommand{\bold}{\textbf}

\begin{document}
\pgfdeclaredecoration{ddbond}{initial}
{
\state{initial}[width=4pt]
{
\pgfpathlineto{\pgfpoint{4pt}{0pt}}
\pgfpathmoveto{\pgfpoint{2pt}{2pt}}
\pgfpathlineto{\pgfpoint{4pt}{2pt}}
\pgfpathmoveto{\pgfpoint{4pt}{0pt}}
}
\state{final}
{
\pgfpathlineto{\pgfpointdecoratedpathlast}
}
}
\tikzset{lddbond/.style={decorate,decoration=ddbond}}
\tikzset{rddbond/.style={decorate,decoration={ddbond,mirror}}}

\begin{tikzpicture}
\chemfig{\lewis{2:4:,O}=[:280,0.8]@{a3}\lewis{5:,N}?[4]-[@{a2,0.5}:262,1.1,,,dotted]Ir?[2](-[:270]Ir?[1]?[3])-[@{a1,0.45},1.2]Ir?[3](-[:270]Ir?[1]?[2])-[:98,1.1,,,dotted]\lewis{7:,N}?[4,1,dotted]=[:80,0.8]\lewis{0:2:,O}}
\chemmove{\draw[-{Stealth[left]},shorten >=2pt](a1).. controls +(80:8mm)  and +(45:5mm) .. (a2);}

\end{tikzpicture}
\end{document}


I really don't know how to fix it. Any pointers on info that I could check would be really appreciated because all my searches have failed on this.

• Please see tex.stackexchange.com/a/129914 Does it help? – cgnieder Nov 2 '14 at 23:23
• Thanks but it dosen't. I've been looking around and i think the problem is with the \chemmove option in the chemfig manual says: "Actually, the \chemmove command puts its argument in a “tikzpicture” environment with the options “remember picture, overlay”. So it looks like there might be a problem with that and i cant figure out how to fix it. Thanks anyways. – Leothan Nov 3 '14 at 2:51
• Well, the idea behind the post I linked is to disable externalization for the piece of code that doesn't work... That really doesn't work? Strange... – cgnieder Nov 3 '14 at 6:41