Diagraph is a very very small application that allows you to draw simple block diagram in LaTeX. It should be enough, for example, for those of you that need block diagrams for system and control theory.
These are the main references
- Official page
- Author's webpage (where you can download the binaries)
Unfortunately this program is not an open source program, and it looks like the last version was published 10 years ago. I find this program quite bug-free, but don't expect exceptional features.
The main advantage of using this program for your block diagrams is that the picture you'll obtain will be perfectly consistent with the rest of your document, because lines, blocks, text and formulas are produced by LaTeX itself!
Installation
Diagraph is distributed as a binary file you just have to copy on your computer (possibly in a directory that is included in your PATH variable).
You can get the binaries from the author's webpage. No real installation is needed.
Usage
The very first thing you have to do is to draw your block diagram on a piece of paper. I didn't say 'think about your diagram', I said 'draw it"! :-) This because you'll need to follow it when writing your code for diagraph. Here is an example:
Now that you have your block diagram, you can start writing down the "code" that diagraph needs to generate your figure. Here is the code I wrote:
R(1)
p
a(feedback)
R(1)
b(3,1,"$C(s) = \frac{B(s)}{A(s)}$")
c("Controller")
R(1)
p
a(disturb)
R(1)
b(2,1,"$W(s)$")
c("Plant")
r(1)
k(sensor)
R(1)
g(sensor)
d(1.5)
l(feedback)
U(feedback)
m
g(sensor)
y(-1.5)
d!(1.5)
L!(0.5)
b(5,1,"$\hat\theta(t+1) = f\left[y,\hat\theta(t);t\right]$")
c("Update law")
l!(1)
U!(2.5)
g(disturb)
y(1)
t(r)
c("$~d(t)$")
D(1)
p
I won't go into the details of this code, you can find everything on the online manual page.
Just try to follow it, keeping in mind that lower case r,l,u,d are segments towards right, left, up and down. Uppercase letter are arrows. ! make it dashed. a are adders, p and m are plus and minus. b is a block, c is a comment. k is a dot, n a label, g means goto.
When you write your code you just have to start from the top left corner of your drawing and follow the lines.
This code has to be saved in a .grp file. The following step consist in running
diagraph yourfile.grp
which will convert your .grp file in a .tex file. Just include it in your LaTeX document, for example with the command
\dia{filename}
where \dia has been defined ad
\newcommand{\dia}[1]
% 1 nomefile
{ \setlength{\unitlength}{1cm}
\begin{figure}[htbp]
\centering
\input{diagrams/#1}
\end{figure}
\setlength{\unitlength}{1pt} }
and you'll be done!
Note that in my \dia command I set \unitlength equal to 1 cm. This gives the scale of your block diagram, so the unit of measures becomes 1 cm. It's a good idea to set it back to the default 1pt after that.
Conclusions
If your document requires a lot of block diagram, then Diagraph can be a good choice. I would say it's one of the best choices if you need to insert complicated formulas in your blocks, because you are able to insert anything that you can write in LaTeX.
On the contrary, if your diagram contains fancy shapes, diamonds, stars, curly arrows and things like that, you won't be able to do that (in a reasonable amount of time) with Diagraph.

