3

I have a figure of a graph with 8 nodes. I want to draw arrows, s.t. they will point to some of the nodes (for example I want to draw arrows pointing to 4 of the nodes). Also, next to each arrow I want to write some text. To do so, I used this webpage: http://en.wikibooks.org/wiki/LaTeX/Picture#Arrows and I thought that I have to write each arrow separately and to fix the placement manually. However, I can not move the arrow from the position where it is. Any ideas?This is the result Here is the complete code that I used:

 \\documentclass[11pt]{article}
\usepackage{tikz}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\tikzset{%
   point/.style = {fill=black,inner sep=1pt, circle, minimum width=3pt,align=right,rotate=60},
   } 
\tikzstyle{weight} = [font=\scriptsize]  
\tikzstyle{vertex}=[circle,fill=blue!20]

\makeatletter
\setlength{\@fptop}{0pt}
\makeatother

\section{Some section}

\begin{figure}
 \centering
 \begin{subfigure}{0.5\textwidth}
 \resizebox{0.7\textwidth}{!}{
 \begin{tikzpicture}
  [scale=.8,auto=right]
      \put(0,10){\vector(1,0){20}}
      \node[vertex] (v1) at (1,10)  {$a$};
      \node[vertex] (v2) at (1,8)  {$b$};
      \node[vertex] (v3) at (1,6)  {$c$};
      \node[vertex] (v4) at (1,4)  {$d$};
      \node[vertex] (v5) at (8,10)  {$e$};
      \node[vertex] (v6) at (8,8)  {$f$};
      \node[vertex] (v7) at (8,6)  {$g$};
      \node[vertex] (v8) at (8,4)   {$h$};

     \draw[->] (v1)--(v8);
     \draw[->] (v1)--(v5);
     \draw[->] (v2)--(v5);
     \draw[->] (v2)--(v6);
     \draw[->] (v3)--(v6);
     \draw[->] (v3)--(v7);
     \draw[->] (v4)--(v7);
     \draw[->] (v4)--(v8);
 \end{tikzpicture}
 }

 \caption{I want to place the arrow s.t. it will point to node "a". Also I want to insert some text above the arrow}
    \label{fig:1}
    \end{subfigure}
    \hspace{4em}%
    \caption{I want to place the arrow s.t. it will point to node "a". Also I want to insert some text above the arrow.}\label{fig:animals}
\end{figure}




\end{document}
5
  • Are all of those packages necessary to your question? Please minimise your example to focus on the relevant parts of it. You should only include enough to make the document compile and clearly illustrate your question or the problem you are asking about. See how to make a minimal working example (MWE) for help.
    – cfr
    Dec 25, 2014 at 0:34
  • Which arrow should point to a? Do you just want \draw[<-] (v8)--(v1); for the diagonal arrow? (That is v8 to v1 rather than v1 to v8?) Where should the text go exactly?
    – cfr
    Dec 25, 2014 at 0:40
  • 1
    @cfr I already updated the code; I want a short arrow that starts right before node "a" (starts from nowhere basically) and points to "a" Dec 25, 2014 at 0:45
  • @cfr the text should be above the arrow Dec 25, 2014 at 0:47
  • 1
    I've edited the tags since your question is really about the diagram (the fact that it is floating isn't the issue you're asking about). But if you disagree, feel free to roll-back or edit my changes.
    – cfr
    Dec 25, 2014 at 1:12

1 Answer 1

3

Possibly something like this?

Pinned node

This was produced using the pin facility for labelling nodes. Note that I've updated your code to use \tikzset consistently since \tikzstyle is deprecated.

\documentclass[tikz, border=10pt]{standalone}

\begin{document}

  \tikzset{%
    point/.style = {fill=black,inner sep=1pt, circle, minimum width=3pt,align=right,rotate=60},
    weight/.style={font=\scriptsize},
    vertex/.style={circle,fill=blue!20}
  }

  \begin{tikzpicture}
    [scale=.8,auto=right]
    \put(0,10){\vector(1,0){20}}
    \node[vertex, pin={[pin edge=<-, pin distance=10pt]105:{Label Here}}] (v1) at (1,10)  {$a$};
    \node[vertex] (v2) at (1,8)  {$b$};
    \node[vertex] (v3) at (1,6)  {$c$};
    \node[vertex] (v4) at (1,4)  {$d$};
    \node[vertex] (v5) at (8,10)  {$e$};
    \node[vertex] (v6) at (8,8)  {$f$};
    \node[vertex] (v7) at (8,6)  {$g$};
    \node[vertex] (v8) at (8,4)   {$h$};

    \draw[->] (v1)--(v8);
    \draw[->] (v1)--(v5);
    \draw[->] (v2)--(v5);
    \draw[->] (v2)--(v6);
    \draw[->] (v3)--(v6);
    \draw[->] (v3)--(v7);
    \draw[->] (v4)--(v7);
    \draw[->] (v4)--(v8);

  \end{tikzpicture}

\end{document}
1
  • 1
    @user3371223 You're welcome. pins are neat, aren't they? I just didn't initially understand you question since your diagram already included lots of arrows so I thought you meant one of those ;).
    – cfr
    Dec 25, 2014 at 1:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .