I am having trouble with including a tikz flow chart in my code.
In my preamble I have included
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes,arrows}
and this is the flow chart:
\begin{figure}[hc]
\begin{tikzpicture}[node distance = 4cm, auto]
% Place nodes
\node [block] (Bio) {Biological Processes};
\node [block, below of=Bio] (Nut) {Nutrient Levels};
\node [block, left of=Nut] (Growth) {Growth/Mortality Rates};
\node [block, right of=Nut] (Predprey) {Predator-Prey Interactions};
\path [line] (Bio) -- node[name=uptake] {} (Nut);
\path [line] (Bio) -- node[name=grazing] {} (Growth);
\path [line] (Bio) -- node[name=pgrowth] {} (Predprey);
\end{tikzpicture}
\caption{\textbf{The biological processes governing the dynamics of plankton populations}}
\label{bioprocesses}
\end{figure}
I have another similar flow chart further down in my code, which is of a similar format
\begin{figure}[hc]
\begin{tikzpicture}[node distance = 3cm, auto]
\node [block] (Nitr) {Nitrates};
\node [block, below of=Nitr] (Phyto) {Phytoplankton};
\path [line] (Nitr) -- node[name=uptake] {nutrient uptake} (Phyto);
\node [block, below of=Phyto] (Zoo) {Zooplankton};
\path [line] (Phyto) -- node[name=grazing] {grazing} (Zoo);
\node [output, right of=Phyto] (Pgrowth) {};
\node [output, right of=Zoo] (Zgrowth) {};
\node [output, below of=Zoo] (Zdeath) {};
\path [line] (Phyto) -- node[name=pgrowth] {growth} (Pgrowth);
\path [line] (Zoo) -- node[name=zgrowth] {growth} (Zgrowth);
\path [line] (Zoo) -- node[name=zdeath] {death} (Zdeath);
\path[line] (Phyto) -- ([xshift=-1.75cm,yshift=0cm]Phyto.west) |- node[name=nutre] {nutrient recycling} (Nitr);
\end{tikzpicture}
\caption{\textbf{Population Interactions}}
\label{flowchart}
\end{figure}
The thing that I do not understand is WHY flow chart 1 can only be placed in the same chapter as flow chart 2 (it compiles perfectly here). Every time I try to place it elsewhere, it comes up with:
package pgfkeys error i don't know the key '/tikz/line'
package pgfkeys error i don't know the key '/tikz/block'
Surely if it compiles in one chapter then I should be able to copy and paste it into another and it should still work?
EDIT: Minimal Example
\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes,arrows}
\begin{document}
\section{FIRST SECTION}
Here is my first section.
\begin{figure}[hc]
\begin{tikzpicture}[node distance = 4cm, auto]
\node [block] (main) {MAIN};
\node [block, below of=main] (Opt1) {Option 1};
\node [block, left of=Opt1] (Opt2) {Option 2};
\node [block, right of=Opt1] (Opt3) {Option 3};
\path [line] (main) -- node[name=line1] {} (Opt1);
\path [line] (main) -- node[name=line2] {} (Opt2);
\path [line] (main) -- node[name=line3] {} (Opt3);
\end{tikzpicture}
\caption{\textbf{First diagram}}
\label{diagram1}
\end{figure}
\section{SECOND SECTION}
Here is my second section.
\begin{figure}[hc]
\begin{tikzpicture}[node distance = 3cm, auto]
\node [block] (Top) {Top Box};
\node [block, below of=Top] (Middle) {Middle Box};
\node [block, below of=Middle] (Bottom) {Bottom Box};
\node [output, below of=Bottom] (output) {};
\path [line] (Top) -- node[name=down1] {line down} (Middle);
\path [line] (Middle) -- node[name=down2] {line down} (Bottom);
\path [line] (Bottom) -- node[name=down3] {line down} (output);
\end{tikzpicture}
\caption{\textbf{Second diagram}}
\end{figure}
\end{document}
lineandblock. Is the\tikzsetdefining these in a LaTeX group (starting with\beginand ending with\end)? I advice you to move this assignment (the\tikzsetcommand) to the preamble. We could help you more if we see a minimal working example (MWE). – Qrrbrbirlbel May 05 '13 at 12:35\documentclass{...}and ending with\end{document}. – jub0bs May 05 '13 at 12:35lineandblockdefined? (Thepgfplotserror also saysConsider writing \pgfplotsset{compat=1.8} into your preamble..) – Qrrbrbirlbel May 05 '13 at 13:10I have added in the following to the preamble and it seems to work.
\tikzstyle{block} = [rectangle, draw, fill=blue!20, text width=5em, text centered, rounded corners, minimum height=4em] \tikzstyle{line} = [draw, text centered , -latex'] \tikzstyle{output} = [fill=white]Thanks again, very kind of everyone.
– KEJ May 05 '13 at 13:24\tikzsetas per Should \tikzset or \tikzstyle be used to define TikZ styles? – Qrrbrbirlbel May 05 '13 at 14:05lineandblockare defined in theshapesTikZ library, which is loaded here... – jub0bs May 05 '13 at 14:09