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.

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?

share|improve this question
3  
I think it would help if you provide a minimal working example (MWE) that illustrates your problem. –  Tobi Sep 18 '11 at 17:49
add comment

2 Answers 2

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}

enter image description here

share|improve this answer
add comment

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.
    \draw (0,0) circle [radius=1cm];
\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}
    \draw (0,0) circle [radius=1cm];
    \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.

share|improve this answer
1  
+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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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