Thanks.
\begin{tikzpicture}[x=2cm,y=2ex]
no ??
Probably is not what you want but you can draw your tikzpicture on an
external pdf and the include with \includegraphics[width=\linewidth]
{external_tikzpicture}.
Ignasi
Hi,
This is something I've tried to figure out myself. Unfortunately, I've
never managed to figure out how to do this (with tikz). The best thing
I can suggest is that you just put your tikzpicture in a tex or latex
box.
Regards,
Marc van Dongen
\resizebox{\linewidth}{!}{%
... your tikz stuff ...
}
needs package graphicx
Herbert
Here you have a box containing a TikZpicture of exactly 200pt x 150pt
\begin{document}\makeatletter
\setbox0=\hbox{%
\begin{tikzpicture}[x=1pt,y=1pt]
\path [use as bounding box,red] (0,0) rectangle (200pt,150pt);
\draw (0,20) -- ++(20,0) node [blue] {Hello}
[->,very thick,orange] -- ++(0,40) node [green,anchor=south]
{\Large Wolrd};
\end{tikzpicture}%
}
box0:\quad wd=\the\wd0\quad ht=\the\ht0\quad dp=\the\dp0
\fbox{\box0}
\end{document}\endinput
Would you 100pt x 75pt ? Then add [scale=.5] in the {tikzpicture} envir.
options.
\documentclass{book}
\usepackage{tikz}
\newsavebox\mybox
\begin{document}
\newcommand\myscalefactor{1}
\newcommand\tikzcontent{%
\begin{tikzpicture}
\pgftransformscale{\myscalefactor}
\draw (-4,0)--(4,0);
\node {root} child {node {left}} child {node {right} child {node
{child}}
child {node {child}} };
\end{tikzpicture}}
\savebox\mybox{%
\fbox{\tikzcontent}}
\usebox{\mybox}
\pgfmathparse{\textwidth/\wd\mybox}
\edef\myscalefactor{\pgfmathresult}
\noindent\fbox{\tikzcontent}
\noindent \rule{\textwidth}{2pt}
\end{document}
the nodes should not define the natural size of the picture or the
result will be wrong (remove the \draw to see the effect).
--
Ulrike Fischer
What do you think about [use as bounding box] ?
>
> What do you think about [use as bounding box] ?
[use as bounding box] will override the automatic bounding box
calculation done by pgf/tikz. This will give you a box of a known size
that you can scale to a given size. This will scale everything including
text in nodes. This is not what the OP was asking for.
does not scale the text (I mean the fonts...)
But the OP is not very clear on his intentions may be.
Just use a dummy object of the required width.
Try the code below with the two offered versions of \documentclass.
See comments inside the code below.
HTH
Itay
<code>
\documentclass{article} % Full width text
%\documentclass[twocolumn]{article} % Narrow width text
\usepackage{tikz}
\begin{document}
\fbox{% % Depict the actual tikzpicture width.
\begin{tikzpicture}
% The next line forces a picture of width ~ \linewidth.
% \linewidth is determined by the class option.
% May replace with \textwidth, or any other tex length.
\path (0cm,0cm) -- (\linewidth, 0cm);
\draw[line width=4pt] (1,-3) -- ++ (0,6)
node[anchor=south] {This is a 4pt line};
\end{tikzpicture}%
}
% The next line demonstrates that we didn't scale
% the objects inside tikzpicture.
This rule has width of 4pt: \rule{4em}{4pt}
\end{document}
</code>
--
Itay Furman it...@fastmail.fm
--------------------------------------
http://longitude.weizmann.ac.il/~itayf
--