Add anchor=base
to your nodes:

\documentclass[varwidth]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\newcommand*{\ident}[1]{\texttt{\small #1}}
\tikzstyle{refines} = [->, >=open triangle 45]
\newcommand{\refi}[3]{$\begin{tikzpicture}[baseline]%
\node[anchor=base] (A) {#1};%
\node[anchor=base] (B) [right of=A, node distance=4em] {#3};%
\draw[refines] (A) -- node[midway,above=-2pt] {#2} (B);%
\end{tikzpicture}$}
\begin{document}
this is a test \refi{\ident{1}}{\scriptsize text}{\ident{2}}\ident{2} that continues here
this is a test \refi{1}{\scriptsize text}{1}\ident{2} that continues here
\end{document}
This ensures that the baseline of the text in the node sits at level 0
.
However, there are two problems: firstly, as @rainer says, depth and height of material in the nodes can make the arrow stop being horizontal; secondly, your code does nothing in the direction of providing an exensible arrow that stretches with the material above the arrow.
The first problem could be used by using the nice tikz-cd
package, see e.g. https://tex.stackexchange.com/a/113449/15925. But that won't solve the second one. So I think it is easier let tikz
take care of only the arrow and the text above it, and leave the rest to ordinary maths placement:

\documentclass{article}
\usepackage{tikz,mathtools}
\usetikzlibrary{arrows}
\newcommand*{\ident}[1]{\texttt{\small #1}}
\tikzstyle{refines} = [->, >=open triangle 45]
\newsavebox{\mytempbox}
\newcommand{\refi}[3]{%
\sbox{\mytempbox}{\hbox{\( \scriptstyle\mkern5mu#2\mkern17mu \)}}
\( #1
\tikz[baseline=-0.5ex]{\draw[refines] (0,0) --
node[midway,above=-0.3ex]{\usebox\mytempbox} (\wd\mytempbox,0);}
#3 \)}
\begin{document}
This is a test \refi{\ident{1}}{\text{text}}{\ident{2}}\ident{2} that continues here.
This is a test \refi{1}{\text{longer text}}{1} that continues here.
A further test \refi{j_2}{\alpha-x e^{p/q}}{a^2} with more text.
\end{document}
The technique here is to save the material to place above the arrow in a box (I written this assuming it is math mode material). That box is then used to specify the length of the arrow and its contents are placed above the arrow. I have added sufficient space around the text so that overlap with the rather large arrow head does not occur.
First of all, I would like to recommend you to not use \tikzstyle
to define your styles in favor of \tikzset
(for further information see Should \tikzset or \tikzstyle be used to define TikZ styles?).
Another remark: I noticed you used both \draw
and \path
; actually, \draw
is a shortcut for \path[draw]
thus, as your style line
already contains the key draw
, there's not difference in using one or the other one. Notice: only in case both exploit the line
style.
Also, the connections can be drawn much more easily thanks to a loop: indeed, most of the lines of code are identical.
Said that, the straight way to solve the problem is to use the library calc
, which helps in defining a commodity coordinate useful to draw the paths.
\documentclass{report}
\usepackage{tikz}
\definecolor{arm}{RGB}{100,140,171}
\usetikzlibrary{arrows,calc,positioning,shapes.geometric}
\begin{document}
\pagestyle{empty}
\begin{figure} [htbp]
\hspace{-1.9cm}
\resizebox{!}{7.5cm}{
\begin{tikzpicture}[node distance = 1.5cm, auto,>=stealth]
\tikzset{los/.style={diamond, draw,fill=arm,text width=3em, text badly centered, text=white, node distance=3cm, inner sep=0pt}}
\tikzset{quadri/.style={rectangle, draw, fill=arm, text width=6em, text centered,text=white , rounded corners, minimum height=2.5em}}
\tikzset{line/.style={draw, thick, color=black, -latex'}}
\node[quadri] (A) {A};
\node[quadri, below of=A, node distance=1.6cm] (B) {B};
\node[quadri, below left=1cm and 2cm of B ] (C) {C};
\node[los, below of=C , node distance=2.2cm] (D) {D};
\node[quadri,below left=1cm and 1.6cm of D] (E) {E};
\node[quadri,below of=E, node distance=1.6cm](F) {F};
\node[quadri,below of=D, node distance=1.97cm](G) {G };
\node[quadri,below of=G, node distance=1.6cm](H) {H};
\node[quadri,below right=1cm and 1.6cm of D] (I) {I};
\node[quadri,below of=I, node distance=1.6cm](J) {J};
\node[quadri, below right=1cm and 2cm of B ] (K) {K};
\node[quadri,below left=1.3cm and 0.22cm of K] (L) {L};
\node[quadri,below of=L,node distance=1.6cm] (M) {M};
\node[los,below right of=K,node distance=3cm] (O) {O};
\node[quadri,below left=1cm and 0.05cm of O](P){P};
\node[quadri,below of=P, node distance=1.6cm](Q) {Q};
\node[quadri,below right=1cm and 0.05cm of O](R){R};
\node[quadri,below of=R, node distance=1.6cm](S) {S};
\node[quadri,right of=A ,node distance=3.5cm](T) {T};
\node[quadri, text width=7em,right of=T ,node distance=3.4cm](U){U};
\foreach \source/\dest in {
A/T,T/U,A/B,B/C,B/K,C/D,E/F,G/H,I/J,K/L,K/O,
L/M,P/Q,R/S}{
\path [line] (\source) -- (\dest);
}
\path [line] (D) -| node [near start,above] {$=0$} (E);
\path [line] (D) -- node[right] {$=1$} (G);
\path [line] (D) -| node [near start,above] {$=0$} (I);
\path [line] (O) -| node [near start,above] {$=1$} (P);
\path [line] (O) -| node [near start,above] {$>1$} (R);
% useful coordinate:
% it is defined as half way between S and Q shifted
% below of 1 cm
\coordinate (below scheme) at ($(S)!0.5!(Q)-(0,1)$);
% path from U to the south of the scheme
\path [line,-] (U.east) -- ($(U.east)+(1.5,0)$) |- (below scheme); % I used again the style line, but - removes the arrow that in this case should not be deployed
\path [line] (S|-below scheme)--(S);
\path [line] (below scheme)-|(M);
\end{tikzpicture}
}
\caption{Flowchart}
\label{fig:flowchart}
\end{figure}
\end{document}
The result:

If your aim is to connect all the leaves of the tree, you might exploit a different solution:
% = = = = = = = = = = = = = = = = = = = =
% THIS IS TO CONNECT U TO all
% = = = = = = = = = = = = = = = = = = = =
\coordinate (below scheme) at ($(F)-(0,1)$);
\path [line,-] (U.east) -- ($(U.east)+(1.5,0)$) |- (below scheme); % I used again the style line, but - removes the arrow that in this case should not be deployed
\foreach \module in {F,H,J,M,Q,S}
\path [line] (\module|-below scheme)--(\module);
The snippet should replace:
% useful coordinate:
% it is defined as half way between S and Q shifted
% below of 1 cm
\coordinate (below scheme) at ($(S)!0.5!(Q)-(0,1)$);
% path from U to the south of the scheme
\path [line,-] (U.east) -- ($(U.east)+(1.5,0)$) |- (below scheme); % I used again the style line, but - removes the arrow that in this case should not be deployed
\path [line] (S|-below scheme)--(S);
\path [line] (below scheme)-|(M);
in the previous document.
The new code defines the commodity coordinate (below scheme
) to be 1cm south of F
. Now, by exploiting the ability of the calc
library to compute intersections, each arrow is defined as a path starting from module |- below scheme
towards module
. Please refer to the pgfmanual for further information on the calc
library.
This provides you:

Best Answer
I'm a bit late.. however this is what you need with my original code:
The result:
An improved version (requires the
xparse
package):The result:
Disclaimer
With evince, I'm not able to correctly visualize the fading and the shadow; it works, at least for me, with Okular, Adobe reader and Preview (on Mac).
Taking as reference the improved example, that allows some more customization, let's have a look to the code.
At first it is defined the fading
giving it a name and specifying that the top color should be opaque and the bottom color almost transparent. Actually, the fading is just applied on the shadow of the arrow; indeed, when defining the style in which the arrow is filled
arrowfill
the fading is passed as part of the shadow:This style receives a parameter that later will be used to set the background color and the arrow direction. Actually, the style is passed to another style,
arrowstyle
that really defines how the arrow is:It receives 3 parameters: the first one is the height of the arrow, the second is the color in which the border of the arrow is colored and the third is passed to
arrowfill
. It also declares that the shape is asingle arrow
and which is itssingle arrow head extend
.Finally, the arrow is built by means of the command:
Here the option
baseline=-0.5ex
says that the arrow is vertically centred in the line; thenode
receives 4 parameters: 3 of them are optional with default values and are passed to the style developed, while the last one is the text that eventually goes inside the arrow.Notice that you can specify the arrow direction by means of the key
shape border rotate
and you don't need anything special to do so: just add it at the third optional argument.Actually, by writing the comments I realized that one argument could be saved, that is the border color of the arrow, but I think in this way things are more clear.