In tikz I have three nodes as following:


\usepackage{pgf, tikz}

\usetikzlibrary{arrows, automata}



\begin{tikzpicture}[>= stealth, shorten >= 1pt,node distance = 3cm,semithick%, auto]

\tikzstyle{every state}=[draw = black,thick,fill = white]

\node[state] (p11) {$p_{1,1}$};

\node[state] (p12) [right of=p11] {$p_{1,2}$};

\coordinate (Middle) at ($(p11)!0.5!(p12)$);

\node[state] (t1) [below of=Middle] {$t_1$};



And I want to add label at the center of nodes, then have the label pointed to each node. Like below:

enter image description here

How can I do it? Btw I don't have auto property enabled for tikzpicture because it will mess up my midway label within edge.

Any help is appreciated. Thank you!

EDIT: full code updated

  • 1
    Welcome to TeX.SX! Please post compilable examples, not just fragments.
    – user31729
    Mar 31 '16 at 21:30
  • Please add the \documentclass{..} line as well: it is better to post a full minimal working example that starts with a \documentclass command, has a minimal preamble and then \begin{document}...\end{document}. The code should compile and be as small as possible to demonstrate your problem. This makes it much easier for people to help you --- and much more likely that they will!
    – user30471
    Mar 31 '16 at 21:47

Here's a simple modification:

  [% \tikzstyle is deprecated - use \tikzset{} instead
    >= Stealth,
    shorten >= 1pt,
    node distance = 3cm,
    every state/.style={draw = black, thick, fill = white},
  \node[state] (p11) {$p_{1,1}$};
  \node[state] (p12) [right of=p11] {$p_{1,2}$};
  \coordinate (Middle) at ($(p11)!0.5!(p12)$);
  \node[state] (t1) [below of=Middle] {$t_1$};
  \node (here) at ($(t1)!1/2!(Middle)$) {My label};
  \path [->] (here) edge (p11) edge (p12) edge (t1);

which yields

modification for label

I've partially updated the syntax to use arrows.meta and avoid \tikzstyle. However, ideally, you would also use the positioning library and its syntax, too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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