Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
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

1 Answer 1

up vote 4 down vote accepted

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

share|improve this answer
    
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

Not the answer you're looking for? Browse other questions tagged or ask your own question.