You need tikzscale
package. Save the contents
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\node at (0,0) {Me};
\end{tikzpicture}
as myfig.tikz
(say) and use \includegraphics
Code:
\documentclass{article}
\usepackage{tikz}
\usepackage{tikzscale}
\usepackage{filecontents} %% only for this demo
\begin{filecontents*}{myfig.tikz}
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\node at (0,0) {Me};
\end{tikzpicture}
\end{filecontents*}
\begin{document}
\begin{figure}[htb]
\centering
\includegraphics[width=0.5\textwidth]{myfig.tikz}
\caption{This figure has a width which is a factor of text width}
\end{figure}
\begin{figure}[htb]
\centering
\includegraphics[width=0.2\textwidth]{myfig.tikz}
\caption{This figure has a width which is a factor of text width}
\end{figure}
\end{document}

Unlike \resizebox
, the fonts are not scaled in-appropriately. If you want to scale fonts too, use \begin{tikzpicture}[transform shape]
instead of \begin{tikzpicture}
.
With \resizebox
from graphicx
:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}[htb]
\centering
\resizebox{0.5\textwidth}{!}{%
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\node at (0,0) {Me};
\end{tikzpicture}
}%
\caption{This figure has a width which is a factor of text width}
\end{figure}
\begin{figure}[htb]
\centering
\resizebox{0.2\textwidth}{!}{%
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\node at (0,0) {Me};
\end{tikzpicture}
}%
\caption{This figure has a width which is a factor of text width}
\end{figure}
\end{document}

tikz
. – Sigur Jan 22 '14 at 0:15\resizebox[\textwidt][!]{...}
doesn't seem to work either. – user41709 Jan 22 '14 at 0:25tikz
using\begin{tikzpicture}[scale=.7]
for example. But this will change the scale of coordinates. – Sigur Jan 22 '14 at 0:26\resizebox
works. You should use it as follows:\resizebox{\textwidth}{!}{\begin{tikzpicture}...\end{tikzpicture}}
– Herr K. Jan 22 '14 at 0:30