# Why does standalone truncate my tikzpicture?

While I was testing an answer of mine, I realized I had to set the standalone border option to border={2mm 2mm 14mm 2mm} because simply with border=2mm the image was truncated.

Why?

\documentclass[tikz, border=2mm]{standalone}
%\documentclass[tikz, border={2mm 2mm 14mm 2mm}]{standalone}
\usetikzlibrary{cd}
\usepackage{amsmath, amssymb}
\begin{document}
\begin{tikzcd}%
&[-30pt] \ker(f) \arrow[dl, phantom, sloped, "\supset"] \arrow[dr, phantom, sloped, "\subset"]&[-30pt] & &[-75pt] \\[-4pt]
\ker(w) \arrow[rr, phantom, "\subset"]& & E \arrow[rr, "w"] \arrow[rd, end anchor={[xshift=.5em]north west}, "\pi_f"] \arrow[dd, swap, "f"] & & \mathbb{K}\\
& & & E/\ker(f) \simeq Im(f) \arrow[ru, dashrightarrow, start anchor={[xshift=1.1em]north west}, swap, "w'"]& \\
& & F & &
\end{tikzcd}%
\end{document}


• The bounding box appears to be computed incorrectly. Possibly because of the [-75pt] – egreg Nov 12 '16 at 11:40
• @egreg It's that, of course, but it's necessary, otherwise I don't get the desidered alignment. Thank you! – CarLaTeX Nov 12 '16 at 15:22
• You should use \mathllap/\mathclap/\mathrlap instead of playing with global settings. Voss's Mathmode.pdf has an example regarding ∑_{something too long}. – Symbol 1 Nov 12 '16 at 18:09
• By the way: The au­thor con­sid­ers this pack­age now as be­ing too old and af­flicted with too many ty­po­graph­i­cal bugs. That’s why it has been clas­si­fied as “ob­so­lete”, at least for the time be­ing. – Symbol 1 Nov 12 '16 at 18:13
• @Symbol1 I'll study Voss's Mathmode.pdf, thank you! Where is it written that tikz-cd is obsolete? I've found no news googling around... – CarLaTeX Nov 12 '16 at 18:29

Here is an answer combining several tricks:

• define new styles for subsets/supersets
• use \mathrlap for overlay part
• use \mathord to control the spacing before \mathrlap
• Im should be \operatorname{Im}.
• usage of column sep= to avoid the diagram being too wide.
• add additional & to create spaces on the right. (This is dirty!)

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{cd}
\usepackage{amssymb,mathtools}
\begin{document}
\tikzcdset{
subset/.code={\tikzcdset{double line}\pgfsetarrows{Arc Barb[length=0 .5].-}},
supset/.code={\tikzcdset{double line}\pgfsetarrows{-.Arc Barb[length=0 .5]}}
}
\begin{tikzcd}[column sep=tiny]
& \ker(f) \dlar[subset] \drar[subset] &&& \\
\ker(w) \ar[rr,subset]& & E \ar[rr, "w"] \drar["\pi_f"] \arrow[dd,',"f"] && \mathbb{K} \\
&&& E/\ker(f)\mathrlap{\mathord{}\simeq Im(f)} \urar[dashrightarrow,',"w'"]& \\
&& F &&&&
\end{tikzcd}
\end{document}

• This can be an answer also of the original question. Great subset and supset but I think mine are more clearly visible. – CarLaTeX Nov 12 '16 at 19:29
• nice solution, but it is difficult to recognize \subsets relation between top left nodes ... – Zarko Nov 12 '16 at 19:46
• @Zarko Then one needs to use, for example,double distance between line centers=1.3ex. – Symbol 1 Jun 18 '17 at 14:04