What would be the best solution to make pgf-umlsd and externalize compatible?
The latter expects \end{tikzpicture} which is "hidden" within sequencediagram environment the first provides. I guess I could convert beginning and the ending of the environment into two commands explicitly invoked at the beginning and ending of the tikzpicture environment meant to be sequence diagram, but it wouldn't survive pgf-umlsd.sty update (i.e. changing environment definition), requiring copy-paste to be redone.
Is there any clever way to solve this problem with as minimal effort as possible and avoiding any copy-pasting?
Should the package author be convinced to provide some begin-like and end-like commands for use within tikzpicture environment?
\documentclass{minimal}
\usepackage[paperwidth=48mm,paperheight=36mm,margin=0pt]{geometry}
\usepackage{parskip}
\usepackage{tikz}
\usepackage{pgf-umlsd}
\usetikzlibrary{external}
%\tikzexternalize
% uncommenting above line gives following error:
% ! File ended while scanning use of \tikzexternal@laTeX@collect@until@end@tikzpicture.
\begin{document}
\null\vfill
\begin{sequencediagram}
\newthread{a}{A}
\newinst[1]{b}{B}
\begin{call}
{a}{call}
{b}{return}
\end{call}
\end{sequencediagram}
\vfill
\end{document}

Let's assume for a moment that author provides three macros (or: we changed pgf-umlsd.sty ourselves):
\sdinit- layers declaration, required before startingtikzpicture\sdbegin- sequence diagram header for use at the beginning oftikzpicture\sdend- sequence diagram footer for use at the end oftikzpicture
Modifying above listing to use them:
\sdinit
\begin{tikzpicture}
\sdbegin
...
\sdend
\end{tikzpicture}
makes externalize happy, but the output is different.

Right part of the rightmost box shadow disappeared. Why? What would be the best way to fix it?
\useasboundingbox ([shift={(0.2,0)}]current bounding box.east);before endingtikzpictureenvironment solves the problem. (I used 0.2 because it's a value used internally inpgf-umlsdas the offset of the first box, thus I get external PDF with symmetrical margins.) – przemoc Feb 17 '13 at 11:43\begin{figure}\centering\begin{tikzpicture/sequencediagram}...\end{tikzpicture/sequencediagram}\end{figure}– LaRiFaRi Jul 26 '13 at 17:43XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017/TeX Live for SUSE Linux) (preloaded format=xelatex)and the problem is still there.As a work-around, I disable the global tikzexternalization. It does not work with
– rriemann Aug 29 '17 at 15:02\tikzset{external/export next=false}. So I use\tikzexternaldisablebefore the sequence diagram and\tikzexternalenableafter it.