2

First, the working code:

\documentclass[journal]{IEEEtran}
\usepackage{libertine}
\usepackage{cite}
\usepackage{url}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{setspace}
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{center}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
  thick,main node/.style={,fill=white!20,draw,font=\sffamily\small\bfseries}]

  \node[main node] (dancing) {dancing};
  \node[main node] (monkey) [below of=dancing] {monkey};

\path[every node/.style={font=\sffamily\small}]
    (dancing) edge node [below] {test} (monkey)
;
\end{tikzpicture}
\end{center}
\end{document}

As shown below, I get overlapping text with the arrow. dancing monkey

Is there a way to change this? Can I also modify the size of the arrow for individual arrows in my graph?

Thanks a lot!

4
  • Welcome to TeX.SX!. It's good that oyu have posted all of the code, however, it's better to post a full minimal working example that people can immediately compile to see what the issues are. This makes it much easier for people to help you.
    – user30471
    Commented Aug 14, 2014 at 4:03
  • Hi @Andrew. I just added working code. Is this better for you?
    – kolonel
    Commented Aug 14, 2014 at 4:12
  • Now I am morally obliged to look at this:) More importantly, it is much easier for any one to play with your code so you are likely to get help more quickly. If you change node [below] {test} to node [right] {test} then the label is printed to the right of the arrow. See customizing-arrows-with-tikz, for example, on how to customise the arrows
    – user30471
    Commented Aug 14, 2014 at 4:16
  • @Andrew thanks for looking into it. I am familiar with basic customization. I am just trying to figure out why the text is overlapping with the arrow.
    – kolonel
    Commented Aug 14, 2014 at 4:19

1 Answer 1

2

This is a possible solution. use rotatebox from graphicx package, or with the help from tikzlibrary postioning with above left=xxcm and xxcm or below right=xx cm and xxcm.

enter image description here

Code

\documentclass{article}
\usepackage{tikz,graphicx}

\usetikzlibrary{arrows,positioning,calc}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
  thick,main node/.style={,fill=white!20,draw,font=\sffamily\small\bfseries}]

  \node[main node] (dancing) {dancing};
  \node[main node,below=3cm of dancing] (monkey) {monkey};

\path[]
    (dancing) edge node [] {\rotatebox[origin=cc]{90}{test}} (monkey)
;
\path[]
    (dancing) edge node [below right=0.5cm and 0.1cm] {test} (monkey)
;
\path[]
    (dancing) edge node [above left=0.5cm and 0.1cm] {test} (monkey)
;
\end{tikzpicture}

\end{document}
2
  • HI @Jesse. Thanks for your answer. Is it possible to make them all rotate 90 degrees?
    – kolonel
    Commented Aug 14, 2014 at 4:35
  • @kolonel Yes, simply copy the \rotate[]{}{test} to wrap the remaining text as the first one did. [above left or below right] are to set the locations while rotate is to rotate the content.
    – Jesse
    Commented Aug 14, 2014 at 4:39

You must log in to answer this question.

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