# Trimming trailing space in tikz nodes

I have defined several tikz figures into custom \myfig commands, which I need to place and rescale within other figures. This simple task is getting really difficult because, for some reason, tikz boxes and nodes are not trimmed right.

I do not understand the general functionning of margins and trailing spaces in with tikz pictures: why is there so much white space underneath this random blue path for example?

\documentclass[a4paper, 12pt]{report}

\usepackage{tikz}
\tikzset{x=1pt, y=1pt, z=1pt}

\begin{document}

Why

% a reusable figure
\def\myfig{\begin{tikzpicture}
[inner sep=0, outer sep=0] % just in case
\path[fill=blue] (0, 0) % a random path
..  controls (10, 10)
and (10, -10) ..
(20, 20) -- cycle;
\end{tikzpicture}}

% an actual figure
in \begin{tikzpicture}
[inner sep=0, outer sep=0] % just in case
\node
[draw, inner sep=0, outer sep=0] % just in case
() at (0, 0) {\resizebox{20pt}{!}{\myfig}};
\end{tikzpicture} the

\LaTeX?

\end{document}


.. and how may I remove it?

I have the feeling that this closely relates to this question which has still not been answered yet.

[EDIT] It has been answered now, so that I can solve my problem in a more general way using this answer :)

Thank you for helping.

You need to clip your figure. As it is, their (invisible) points for curve design with .. controls .. are far below of visible shape.

    \documentclass[a4paper, 12pt]{report}
\usepackage{tikz}
\tikzset{x=1pt, y=1pt, z=1pt}

\begin{document}
Why

% a reusable figure
\def\myfig{\begin{tikzpicture}
[inner sep=0, outer sep=0] % just in case
\clip (0,0) rectangle (20,20);% <--- added
\path[fill=blue] ( 0,  0) % a random path
..  controls (10, 10)
and (10,-10) ..
(20, 20) -- cycle;
\end{tikzpicture}}

% an actual figure
in \begin{tikzpicture}
[inner sep=0, outer sep=0] % just in case
\node
[draw, inner sep=0, outer sep=0] % just in case
at (0, 0) {\myfig};
\end{tikzpicture} the

\LaTeX?
\end{document}

• GREAT ! So the control points were the actual problem. They are invisible so they were driving me mad ^ ^ Cheers :) – iago-lito Apr 3 '16 at 10:25