3

Is there any way to externalise a chemfigscheme with tikz?

At the moment a good fix to externalise simple chemfig pictures is to place them inside a \begin{tikzpicture}...\end{tikzpicture}environment. This can be done automatically, as discussed here.

I am aware that arrows drawn with \chemmove won't work, as per this answer, but I am hoping to find a way to externalise simple schemes, like the one below.

This is my (updated) MWE:

\documentclass{article} 
\usepackage{chemfig}
\usetikzlibrary{external}
\tikzexternalize    
\begin{document}    
\begin{figure}
\centering
\begin{tikzpicture}
\schemestart
\chemfig{A}\arrow{->[\scriptsize above]}\chemfig{B}
\schemestop
\end{tikzpicture}
\caption{}
\end{figure}    
\end{document}

Interestingly, disabling tikzexternalbefore schememestartand re-enabling it immediately afterwards generates the corresponding external figure only for 'A'. Adding a second \tikzexternalenablegenerates a picture also for B. See below:

\begin{figure}
\centering
\tikzexternaldisable
\schemestart
\tikzexternalenable
\chemfig{A}\arrow{->[\scriptsize above]}\tikzexternalenable\chemfig{B}
\schemestop
\caption{}
\end{figure}

Edit: it turned out my MWE was too minimal to reproduce the issue. Here's a list of simple things I found originate errors. I suspect they can be easily fixed.

  1. My arrows are redefined so as to automatically print out label in scriptsize (now triggered manually in the updated MWE).

    This, however, gives the following error:

    TeX capacity exceeded, sorry [input stack size=5000]. \pgf@selectfontorig ->\pgf@selectfontorig
    \nullfont

    That is true any time the font size or weight is varied, anywhere in between \schemestart and \schemestop when in a \tikzpicture environment. For example, \chemnum's standard \cmpd{name} gives a similar error because the compound's label is printed as \textbf{label}. Wrapping the incriminated text in brackets doesn't fix it.

  2. \parbox and \mboxdon't work, possibly because they'd be nested environments?
  3. Bonus: It would be a lifesaver if all my schemes could be redefined a posteriori to be wrapped in tikzpicture, as it was done for \chemfigin the answer linked above.
markellos
  • 461
  • 1
  • 4
  • 15
  • 1
    I do not understand the question... If I wrap the \schemestart .. \schemestop with \begin{tikzpicture} ... \end{tikzpicture}, the figure is externalized correctly. What are you looking for? – wimi Nov 18 '19 at 19:06
  • You're right! See my updated question. – markellos Nov 19 '19 at 11:16

0 Answers0