# Help needed with tikz

I would be very grateful if anyone could help with my questions below. Here's my latex code:

\documentclass[12pt]{report}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{verbatim}

\begin{document}

\tikzstyle{int}=[draw, line width = 1mm, minimum size=8em]

\begin{figure}
\centering

\begin{tikzpicture}[node distance=4.5cm,auto,>=latex']
\node [int] (a) {};
\node (b) [left of=a,node distance=5cm, coordinate] {a};
\node [int] (c) [] {$S$};
\node [coordinate] (end) [right of=c, node distance=5cm]{};
\path[->] (b) edge node {$\gamma$} (a);
\draw[->] (c) edge node {$\psi$} (end) ;
\end{tikzpicture}
\caption{This is a single compartment model}

\end{figure}

\end{document}


I'm a very newbie to tikz and I've had a brief look at the 405-page document by Till Tantau. I have to say, I don't even know where to start. The above code was a template which I've managed to edit to produce the image seen. I don't quite understand what every single code is doing and I'm sure there are bits of codes that aren't needed here. I would like to introduce a loop with an arrow head below the box pointing back at the box (with a label on the arrow:"z"). I was also wondering if anyone could help with making the arrows bolder and perhaps bigger.

Alternatively, I would be grateful if anyone could direct me to exactly what page to read on the tikz documentation to answer these questions.

Thanks

• p 237 for labelled loops with arrows. Use arrows.meta and then see section 16.5 for options. – cfr Jan 1 '15 at 3:28
• @cfr, thanks for that. I'll let you know if I manage to solve it. – John_dydx Jan 1 '15 at 3:33

You can

1. change the thickness of the arrow via ultra thick:

\path[->, ultra thick, blue] (b) edge node {$\gamma$} (a);


or specify an actual line width=:

\draw[->, line width=5pt, red] (c) edge node {$\psi$} (end) ;

2. Draw a loop using the to syntax (violet arrow):

\draw [violet, ultra thick, ->]
([xshift=-1.0cm]a.south) to[out=-120, in=-60, distance=2cm] ([xshift=1.0cm]a.south);

3. Add a node with \node:

\node [below=0.5cm] at (a.south) {$z$};


## Code:

\documentclass[12pt]{report}
\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

%\tikzstyle{int}=[draw, line width = 1mm, minimum size=8em]
\tikzset{int/.style={draw, line width = 1mm, minimum size=8em}}

\begin{figure}
\centering

\begin{tikzpicture}[node distance=4.5cm,auto,>=latex']
\node [int] (a) {};
\node (b) [left of=a,node distance=5cm, coordinate] {a};
\node [int] (c) [] {$S$};
\node [coordinate] (end) [right of=c, node distance=5cm]{};
\path[->, ultra thick, blue] (b) edge node {$\gamma$} (a);
\draw[->, line width=5pt, red] (c) edge node {$\psi$} (end) ;

\draw [violet, ultra thick, ->]
([xshift=-1.0cm]a.south) to[out=-120, in=-60, distance=2cm] ([xshift=1.0cm]a.south);
\node [below=0.5cm] at (a.south) {$z$};

\end{tikzpicture}
\caption{This is a single compartment model}

\end{figure}

\end{document}

• this is absolutely brilliant-spot on! Thanks. – John_dydx Jan 1 '15 at 10:50

\documentclass[12pt]{report}
\usepackage{tikz}
\usetikzlibrary{arrows} % TikZ libraries needed for
% drawing of TikZ pictures in document

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[% definition of own styles in picture
node distance = 5cm,% define distance between nodes and coordinates
auto,               % placement od edge nodes
>=latex',           % define type of arrow
int/.style = {draw, line width = 1mm, minimum size=4em}
]
\node[int]              (a) {This is a text};% make a box with style "int"
% containing a text "This is a text%}
\coordinate[left  of=a] (b);    % define just a point at node distance left from the box
\coordinate[right of=a] (c);    % similarly on the right side of the box
\path[->]   (b) edge node {$\gamma$}  (a)   % left arrow with label $\gamma$
(a) edge node {$\psi$}    (c);  % right arrow
\end{tikzpicture}

\caption{This is a single compartment model}
\end{figure}
\end{document}


For drawing with TikZ is very helpful to read complete chapter "TikZ ist kein Zeichenprogramm".

• @ Zarko, I'll check out the documentation, thanks. – John_dydx Jan 1 '15 at 11:17

Not exactly an answer, but I've taken out the redundant or extraneous bits from the MWE and added some comments:

\documentclass[12pt]{report}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

% define a style for a node (thick lined box, square if any included label is small enough)
\tikzstyle{int}=[draw, line width = 1mm, minimum size=4em]

\begin{figure}
\centering

\begin{tikzpicture}[node distance=4.5cm,auto,>=latex']
% make a thick lined box with a label
\node [int] (c) [] {This is a label};
% define a point to the left of the box, add a label for clarity, remove it when not needed
\node (b) [left of=c,node distance=5cm] {b};
% similarly, define a point to the right of the box
\node (end) [right of=c, node distance=5cm]{end};
% draw arrows from left to right, label them
\path[->] (b) edge node {$\gamma$} (c);
\path[->] (c) edge node {$\psi$} (end) ;
\end{tikzpicture}

\caption{This is a single compartment model}
\end{figure}

\end{document}


Result: