# Remove “white parts” of tikz picture

I have a tikz picture, which consists of a visible part on the left side and a white part on the right side (for some constructive reasons). Now I would like to redefine the size so that the new picture just consists of the left part (without scaling).

How do you do that?

-
I think it would help if you provide a minimal working example (MWE) that illustrates your problem. – Tobi Sep 18 '11 at 17:49

You have to explicitly set the bounding box of the picture. TikZ provides the use as bounding box option to do that. For example

\documentclass{report}
\usepackage{tikz}

\begin{document}
a
\begin{tikzpicture}
\path[use as bounding box, draw] (0,0) rectangle (2,2); % The draw option is given just for demonstration.
\end{tikzpicture}
b
\end{document}


If you want to shrink an already established bounding box, you have to reset it with \pgfresetboundingbox first:

\documentclass{report}
\usepackage{tikz}

\begin{document}
a
\begin{tikzpicture}
\pgfresetboundingbox
\path[use as bounding box, draw] (0,0) rectangle (2,2);
\end{tikzpicture}
b
\end{document}


Other useful options for modifying the bounding box are the trim left and trim right options to tikzpicture. Section 15.7 “Establishing a Bounding Box” of the TikZ manual (v2.10) has all the details.

-
+1 for \pgfresetboundingbox alone. Without it you don't have much change getting the bounding box you want, expect drawing everything you want count for it first, which isn't reasonable for larger pictures. – Martin Scharrer Sep 18 '11 at 18:17

You could use the \clip command to restrict your figure to a certain area (for further details, see Secion 15.8 Clipping and Fading (Soft Clipping) of the pgfmanual). A little example:

\documentclass{article}
\usepackage{tikz}

\begin{document}

text \begin{tikzpicture}[line width=5pt]
\draw (0,0) -- (1,0) -- (1,1) -- cycle;
\draw (2,0) -- (3,0) -- (3,1) -- cycle;
\end{tikzpicture} text

text \begin{tikzpicture}[line width=5pt]
\clip (-0.2,-0.1) rectangle (1.2,1.2);
\draw (0,0) -- (1,0) -- (1,1) -- cycle;
\draw (2,0) -- (3,0) -- (3,1) -- cycle;
\end{tikzpicture} text

\end{document}


-