[Tex/LaTex] Controlling arrow distance from the destination node in TikZ

arrowsnodestikz-pgf

I'm trying to draw a simple diagram in TikZ. I used a code example from the documentation (code below). As you can see on the graphic:

enter image description here

there is a problem with arrows that are not touching the destination nodes. The propblem is especially visible on loop arrows. Even if I draw the simplest diagram, the arrows are always spaced from nodes. In my .tex document I use many packages so this distance may probably result in some other setting from other package.

Is there a way (parameter) I can control the arrow distance from the destination node? How can I change the below code to have the tip of the arrow touch the destination node? The "shorten" param seems to control the distance from the origin node.

\begin{tikzpicture}[->,>=stealth',shorten <=1pt,auto,node distance=2.8cm,semithick]
\tikzstyle{every state}=[fill=red,draw=none,text=white]
\node[initial,state] (A) {$q_a$};
\node[state] (B) [above right of=A] {$q_b$};
\node[state] (D) [below right of=A] {$q_d$};
\node[state] (C) [below right of=B] {$q_c$};
\node[state] (E) [below of=D] {$q_e$};
\path (A) edge node {0,1,L} (B)
edge node {1,1,R} (C)
(B) edge [loop above] node {1,1,L} (B)
edge node {0,1,L} (C)
(C) edge node {0,1,L} (D)
edge [bend left] node {1,0,R} (E)
(D) edge [loop below] node {1,1,R} (D)
edge node {0,1,R} (A)
(E) edge [bend left] node {1,0,R} (A);
\node [right=1cm,text width=8cm,font=\footnotesize] at (C)
{
    The current candidate for the busy beaver for five states. It is
     presumed that this Turing machine writes a maximum number of
    $1$'s before halting among all Turing machines with five states
    and the tape alphabet $\{0, 1\}$. Proving this conjecture is an
    open research problem.
};
\end{tikzpicture}

Preamble:

\pdfoutput=1
\pdfcompresslevel=9
\pdfinfo
{
    /Author (xxx)
    /Title (xxx)
    /Subject (xxx)
    /Keywords (xxx)
}

\documentclass[a4paper,onecolumn,oneside,11pt,wide,floatssmall]{mwrep}

\usepackage{mathtools}
\usepackage{tikz}
\usepackage{pgf}
\usetikzlibrary{arrows,automata}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{bookman}

\usepackage[absolute]{textpos}

\usepackage{geometry}
\usepackage{t1enc}

\usepackage[pdftex, bookmarks=true]{hyperref}

\def\url#1{{ \tt #1}}

\usepackage{listings}

\usepackage[utf8]{inputenc}


\textwidth\paperwidth
\advance\textwidth -55mm
\oddsidemargin-0.9in
\advance\oddsidemargin 33mm
\evensidemargin-0.9in
\advance\evensidemargin 33mm
\topmargin -1in
\advance\topmargin 25mm
\setlength\textheight{48\baselineskip}
\addtolength\textheight{\topskip}
\marginparwidth15mm

\clubpenalty=10000 
\widowpenalty=10000 
\brokenpenalty=10000 
\sloppy

\tolerance4500
\pretolerance250
\hfuzz=1.5pt
\hbadness1450


\renewcommand{\chaptermark}[1]{\markboth{\scshape\small\bfseries    #1}{\small\bfseries \ #1}}
\renewcommand{\sectionmark}[1]{\markboth{\scshape\small\bfseries\thesection.    #1}{\small\bfseries\thesection.\ #1}}

\pagestyle{uheadings}

%\usepackage[pdftex]{color,graphicx}
\usepackage{color,graphicx}

\usepackage[utf8]{inputenc}

\usepackage[sort, compress]{cite}

\usepackage{multirow}
\usepackage{rotating}
\usepackage{longtable}
\usepackage{hyperref}
\usepackage{enumerate}
\usepackage{array}
\usepackage{tabularx}

\usepackage{glossaries}



\makeglossaries

\theoremstyle{definition}
\newtheorem{defn}{Definicja}[section]
\newtheorem{conj}{Teza}[section]
\newtheorem{conjmain}{Teza}
\newtheorem{exmp}{Przykład}[section]

\theoremstyle{plain}
\newtheorem{thm}{Twierdzenie}[section]
\newtheorem{lem}[thm]{Lemat}
\newtheorem{prop}[thm]{Hipoteza}
\newtheorem*{cor}{Wniosek}

\theoremstyle{remark}
\newtheorem*{rem}{Uwaga}
\newtheorem*{note}{Uwaga}
\newtheorem{case}{Przypadek}

\definecolor{ListingBackground}{rgb}{0.95,0.95,0.95}

\begin{document}

\input {glo/glossary}

\lstdefinestyle{incode}
{
basicstyle={\footnotesize},
keywordstyle={\bf\footnotesize\color{blue}},
commentstyle={\em\footnotesize\color{magenta}},
numbers=left, 
stepnumber=5, 
firstnumber=1,
numberfirstline=true,
numberblanklines=true,
numberstyle={\sf\tiny}, 
numbersep=10pt, 
tabsize=2,
xleftmargin=17pt,
framexleftmargin=3pt,
framexbottommargin=2pt,
framextopmargin=2pt,
framexrightmargin=0pt,
showstringspaces=true,
backgroundcolor={\color{ListingBackground}},
extendedchars=true,

captionpos=b,

frame=tb,
framerule=0pt, 
}

\lstdefinestyle{outcode}
{
basicstyle={\footnotesize},
keywordstyle={\bf\footnotesize\color{blue}},
commentstyle={\em\footnotesize\color{magenta}},
numbers=left, 
stepnumber=5, 
firstnumber=1,
numberfirstline=true,
numberblanklines=true,
numberstyle={\sf\tiny}, 
numbersep=10pt, 
tabsize=2,
xleftmargin=17pt,
framexleftmargin=3pt,
framexbottommargin=2pt,
framextopmargin=2pt,
framexrightmargin=0pt,
showstringspaces=true,
backgroundcolor={\color{ListingBackground}},
extendedchars=true,

captionpos=b,

frame=tb,
framerule=0.1pt, 
}

\renewcommand*\lstlistingname{Wydruk}
\renewcommand*\lstlistlistingname{Spis wydrukĂłw}

\pagenumbering{roman}
\renewcommand{\baselinestretch}{1.0}
\raggedbottom
\input {tex/Tytulowa}

\tableofcontents

\listoffigures
\listoftables

\printglossaries

Best Answer

Well, I don't know why it is happening but I know where it is happening. The arrowhead stealth' is the culprit and amazingly it gets affected by the line

\renewcommand{\baselinestretch}{2}

regardless of the amount put inside the definition. You don't see that with other arrow heads. It happens with arrows library specific arrows. Here is a much simpler MWE (I wish you did this for us but anyway)

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}

\begin{tikzpicture}
\node[draw] (A) {$q_a$};
\node[draw] (B) at (1,0) {a};
\draw[-stealth'](A) -- (B);
\end{tikzpicture}

\renewcommand{\baselinestretch}{2}

\begin{tikzpicture}
\node[draw] (A) {$q_a$};
\node[draw] (B) at (1,0) {a};
\draw[-stealth'](A) -- (B);
\end{tikzpicture}
\end{document}

enter image description here

David Carlisle also indicated that there is a font selection issue or absence of it for reasons beyond me. Hence,

\renewcommand{\baselinestretch}{2}\selectfont

brings the arrow back to the node border. But I don't know what it breaks....

Long story short this is very likely to be related to the way how \nullfont declaration is invoked. For example, putting \selectfont\nullfont as the first code inside the TikZ picture also removes the artifact. So at some point before TikZ starts to do its job font selection should be finished so that one can switch to the \nullfont properly.

Thus, David's comment below is very important.