4

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}

enter image description here

Angelo
  • 413

1 Answers1

5

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}

enter image description here

Gonzalo Medina
  • 505,128