TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to produce some diagrams (preferably using TikZ/PGF) using the visual notation given in Enterprise Integration Patterns by Hohpe & Woolf. I'm aware of stencils from the above site, based on Visio, but I'd rather be able to compose them directly in my LaTeX documents. Is anyone aware of PGF library packages that I can use, or failing that how I can create reusable symbols for use in a TikZ/PGF figure?

share|improve this question
Do you want to just have the figures in your document by themselves, or as part of flowcharts (similar to a circuit diagram)? – Jake Jul 11 '11 at 12:38
These symbols would be used multiple times in the same diagram. The diagrams will serve a similar purpose as UML diagrams. The symbols would, I assume, be nodes that I can then attach with edges. In some cases, I would like to be able to annotate these edges with symbols too. – Andrew Matthews Jul 11 '11 at 22:00

Taking an "order" symbol from this page, you can draw it with TikZ in the following way:

  • define an origin for the symbol. I chose the upper left corner of the rectangle
  • draw the elemnt with TikZ
  • create a \newcommand, best giving it a telling name, with at least two parameters for X and Y coordinate
  • now enter the #1 and #2 (X and Y) in all coordinates

The effect is that your component is drawn relatively to the coordinates specified. Here you have an example for the order element:


\newcommand{\EAIOrder}[2]{% X coordinate, Y coordiante
\filldraw[fill=yellow] (#1,#2) rectangle (#1+0.4,#2-0.4);
\filldraw[pattern=north east lines,pattern color=green!50!black] (#1,#2) rectangle (#1+0.4,#2-0.4);%
\draw (#1,#2-0.2) -- (#1-0.2,#2-0.2) -- (#1-0.2,#2+0.2);%
\filldraw[gray,draw=black] (#1-0.2,#2+0.4) circle (0.2);


\begin{tikzpicture}[show background rectangle]


In the same fashion you can define other components and use them together. You can also be fancy and give it more parameters (line color, filling, pattern color, scaling, ...), but be aware that without special efforts (e.g. with package keyval) nine parameters is the maximum.

BTW, the above code produces:

enter image description here

Edit 1: There is of cause a much easier way using a scope. The scope is passed the options for xshift and yshift, this avoids having to insert #1 and #2 into all coordinates. The following produces exactly the same as the code before:


\newcommand{\EAIOrder}[2]{% X coordinate, Y coordiante
\begin{scope}[xshift=#1, yshift=#2]
\filldraw[fill=yellow] (0,0) rectangle (0.4,-0.4);
\filldraw[pattern=north east lines,pattern color=green!50!black] (0,0) rectangle (0.4,-0.4);%
\draw (0,-0.2) -- (-0.2,-0.2) -- (-0.2,+0.2);%
\filldraw[gray,draw=black] (-0.2,0.4) circle (0.2);


\begin{tikzpicture}[show background rectangle]


And as I newly learned, instead of keyval you can use pgfkeys already built in TikZfor fancy enhancements and customizability of your commands

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.