# Tikz's picture: out of the page margin [duplicate]

Possible Duplicate:
How to scale a tikzpicture to \textwidth
Shrink figure only when necessary?

As you can see the third rectangle is out of the right margin...how can I fix this issue?

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\begin{scope}
\draw (0,0) rectangle (5.5,4.5);
\end{scope}

\begin{scope}[xshift=70mm]
\draw (0,0) rectangle (5.5,4.5);
\end{scope}

\begin{scope}[xshift=140mm]
\draw (0,0) rectangle (5.5,4.5);
\end{scope}

\end{tikzpicture}
\end{document}


-

## marked as duplicate by Martin Scharrer♦May 3 '12 at 14:42

You mean how to resize the whole picture down to the text width, right? See Shrink figure only when necessary? and How to scale a tikzpicture to \textwidth This question should be closed as duplicate if so. –  Martin Scharrer May 3 '12 at 14:36

You can use the scale option to tikzpicture, or you can also use \resizebox from the graphicx package; a little example of the latter, making the tikzpicture span the whole \textwidth:

\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{lipsum}

\begin{document}

\lipsum[2]
\noindent\resizebox{\textwidth}{!}{\begin{tikzpicture}

\begin{scope}
\draw (0,0) rectangle (5.5,4.5);
\end{scope}

\begin{scope}[xshift=70mm]
\draw (0,0) rectangle (5.5,4.5);
\end{scope}

\begin{scope}[xshift=140mm]
\draw (0,0) rectangle (5.5,4.5);
\end{scope}

\end{tikzpicture}}

\lipsum[2]
\end{document}


-
Indeed, but adjustbox is even better because it doesn't read the whole thing has macro argument and can be configured to only scale if required. The adjustbox environment also uses by default. See Shrink figure only when necessary? –  Martin Scharrer May 3 '12 at 14:41