TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

Right now, what I have is

\tikzstyle{vertex}=[circle, draw, inner sep=0pt, minimum size=6pt]

        \vertex[label=$p_1$](p1) at (-1,1.5) {};
        \vertex[label=$p_2$](p2) at (1,1.5) {};
        \vertex[label=$p_3$](p3) at (-1,0) {};
        \vertex[label=$p_4$](p4) at (-1,-1.5) {};
        \vertex[label=$p_5$](p5) at (1,-1.5) {};


which produces the following:

bad things

I am fairly new to tikz so I apologize if this is a dumb question, but how do I get it so that, instead of circles, the vertices will only be displayed as the text labels $p_1$, $p_2$, etc. (which should be positioned where the circles currently are)? There will also probably need some padding around the labels so the arrows don't run overlap with them. I'm not sure how to do either of these things.

share|improve this question
Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Which package provides \vertex and \Edge? Judging from the syntax, \vertex is a simple \node and you should not use a label but put $p_i$ in the node text: \vertex … {$p_i$}; (as kan’s answer). – Qrrbrbirlbel May 9 '13 at 1:19
@Qrrbrbirlbel alright. – Alexander Gruber May 9 '13 at 1:29
up vote 8 down vote accepted
    \node (p1) at ( 0, 0) {$p_1$}; 
    \node (p2) at ( 1, 0) {$p_2$};
    \node (p3) at ( 0,-1) {$p_3$};
    \node (p4) at ( 0,-2) {$p_4$};
    \node (p5) at ( 1,-2) {$p_5$};

    \begin{scope}[every path/.style={->}]
       \draw (p1) -- (p3);
       \draw (p3) -- (p4); 
       \draw (p1) -- (p5);
       \draw (p2) -- (p4);
       \draw (p2) -- (p5);



Things of this kind remind me immediately of Commutative diagrams, so here is the incredibly simple tikz-cd code to achieve your desired goal:

p_1 \arrow{d} \arrow{rdd} & p_2 \arrow{ldd} \arrow{dd}\\
p_3 \arrow{d} &     \\
p_4 & p_5 



share|improve this answer
How to scale the picture with tikz-cd without scaling the labels ? I try to find this in the doc, but without success ? – Alain Matthes May 9 '13 at 6:21
@AlainMatthes I think you can use xscale and yscale (or simply scale, which sets both the scales to the same specified value, I think). +1 for showing OP what (s)he wanted to do... – kan May 9 '13 at 9:09
I tried scale but without success. I made a search on the net but with no result – Alain Matthes May 9 '13 at 9:43
@AlainMatthes: I believe you want the row sep and column sep keys. – Charles Staats Feb 5 '14 at 16:00

A solution with tkz-graph is also simple but you need to avoid to mix tikz and tkz-graph You need if you work with tkz-graph to know some principles.

With the example you give, it's easy to use tikz or tikz-cd, tkz-graph is only useful if you need to set up automatically some styles and if you need to draw some complex graph but with some geometrical requests (vertices on a line , on a square, a circle

\usepackage{tkz-graph} % tkz-graph loads tikz


    % initialization
      % vertices
      \Vertex[L=p_1]{p1} \EA[L=p_2](p1){p2}
      \SO[L=p_4](p3){p4} \EA[L=p_5](p4){p5}
      % edges
      \tikzset{EdgeStyle/.style = {->}}
     \Edges (p1,p5)  \Edges (p2,p5)  \Edges (p2,p4)


Comments :

  • \SetGraphUnit If you use some automatic placement, you need to fix the node distance with tkz-graph you can use this macro but possible is d=2 cm inside the options of a Vertex for a local modification
  • \SetVertexMath All the label are in Math Mode, so L=p_3 is enough
  • \GraphInit[vstyle=Empty]the choice of the style. Here the node are circle but no draw
  • \Vertex[L=p_1]{p1} the first vertex as you can see, no need to add ; at the end of the command. The reference is p1 but the label is $p_1$.
  • \EA is for east of (I made this package before the existence of the positioning library). \SOis for south etc... you have also SOEA NOWE etc.
  • It's possible to use personal styles with \tikzset{EdgeStyle/.style = {->}} or \tikzset{VertexStyle/.style = {...}} or \tikzset{EdgeStyle/.append style = {->}} etc.

enter image description here

share|improve this answer

Considering your purpose, it could be easier to use the XY package, just as:


p_1 \ar[d] \ar[ddrr] & & p_2 \ar[dd] \ar[ddll]\\
p_3 \ar[d] & & \\
p_4 & & p_5 



enter image description here

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.