[Tex/LaTex] Division by 0 when combining tikzpicture and resizebox

tikz-pgftikz-qtree

To draw a larger tree, I tried to use

\documentclass[11pt]{article}
\usepackage{tikz-qtree, tikz-qtree-compat}
\tikzset{every tree node/.style={align=center, anchor=north}}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
\resizebox{\linewidth}{!}{%
\Tree [.CP  ] 
}
\end{tikzpicture}
\end{document}

This gives a division by 0 error. However, without the tikzpicture
environment, it works just fine.

\documentclass[11pt]{article}
\usepackage{tikz-qtree, tikz-qtree-compat}
\tikzset{every tree node/.style={align=center, anchor=north}}
\usetikzlibrary{positioning}

\begin{document}
\resizebox{\linewidth}{!}{%
\Tree [.CP  ] 
}
\end{document}

Best Answer

The \resizebox needs to be outside the \begin{tikzpicture}...\end{tikzpicture} environment.