Take the 2-minute tour ×
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.

I am trying to produce a diagram similar to the following (from Wikipedia)


in TiKz. Now, I thought this would be relatively simple, however, I am having trouble getting the elements (the dots) to be of the correct size and am unsure how to elegantly surround the elements in an ellipse. My current TiKz code is


 \begin{tikzpicture}[ele/.style={fill=black,minimum size=2pt,circle}, node distance=7pt]
  \node[ele] (a1) {};
  \node[ele] (a2) [below=of a1] {};
  \node[ele] (a3) [below=of a2] {};
  \node[ele] (a4) [below=of a3] {};
  \node[ele] (b1) [right=of a1,xshift=15pt] {};
  \node[ele] (b2) [below=of b1] {};
  \node[ele] (b3) [below=of b2] {};
  \node[ele] (b4) [below=of b3] {};
  \draw[->,thick] (a1) -- (b4);
  \draw[->,thick] (a2) -- (b2);
  \draw[->,thick] (a3) -- (b1);
  \draw[->,thick] (a4) -- (b3);

which renders as


Can anyone recommend a more elegant means of drawing such a diagram?

share|improve this question
Set inner sep in the ele style to 0. –  Caramdir Jun 5 '11 at 20:22
add comment

1 Answer 1

up vote 12 down vote accepted

 \begin{tikzpicture}[ele/.style={fill=black,circle,minimum width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner sep=-2pt}]
  \node[ele,label=left:$a$] (a1) at (0,4) {};    
  \node[ele,label=left:$b$] (a2) at (0,3) {};    
  \node[ele,label=left:$c$] (a3) at (0,2) {};
  \node[ele,label=left:$d$] (a4) at (0,1) {};

  \node[ele,,label=right:$1$] (b1) at (4,4) {};
  \node[ele,,label=right:$2$] (b2) at (4,3) {};
  \node[ele,,label=right:$3$] (b3) at (4,2) {};
  \node[ele,,label=right:$4$] (b4) at (4,1) {};

  \node[draw,fit= (a1) (a2) (a3) (a4),minimum width=2cm] {} ;
  \node[draw,fit= (b1) (b2) (b3) (b4),minimum width=2cm] {} ;  
  \draw[->,thick,shorten <=2pt,shorten >=2pt] (a1) -- (b4);
  \draw[->,thick,shorten <=2pt,shorten >=2] (a2) -- (b2);
  \draw[->,thick,shorten <=2pt,shorten >=2] (a3) -- (b1);
  \draw[->,thick,shorten <=2pt,shorten >=2] (a4) -- (b3);

enter image description here

share|improve this answer
minimum width=.8pt,inner sep=1pt to get smaller points –  Alain Matthes Jun 5 '11 at 21:32
add comment

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.