I'm using tikz to draw a info flow diagram which contains a few long labels. What I get is unacceptably ugly, mainly resulting from various overlapping between labels and shapes. Ideally, I want the length of line segments dynamically harmonize with the length of texts over it. Is there a way to achieve so?
A minimal example is:
\documentclass[10pt]{article}
\usepackage[usenames]{color} %used for font color
\usepackage{amssymb} %maths
\usepackage{amsmath} %maths
\usepackage[utf8]{inputenc} %useful to type directly diacritic characters
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\tikzstyle{enc}=[circle, draw]
\tikzstyle{entity}=[rectangle, draw]
\begin{tikzpicture}
\node[enc] (app enc) {AEnc};
\node[enc] (quote enc) [below = of app enc] {QEnc};
\node[entity] (app) [right = of app enc] {app};
\node[entity] (challenger) [right=of app] {Challenger};
\draw[<->] (challenger) to
node[auto, swap]{1) $(n,c)$}
node[auto] {5) d}
(app);
\draw[->] (app) to node[auto,swap] {2) $(n,c)$} (app enc);
\draw[dashed,->] (app enc) to node[auto] {3) $appenc_{id} || n||r||CMAC(RK_{QE},.)$} (quote enc);
\draw[dashed, ->] (quote enc) to node[auto] {4) $appenc_{id} || n||r||Sig_{EPID_{sk}}[.]$} (challenger);
\end{tikzpicture}
\end{document}
Best Answer
You can increase the distance between the nodes using
node distance
as an argument to thetikzpicture
environment. Secondly, rather than usingauto
to place the node labels usingleft=<dim>
andright=<dim>
to manually move them into better positions.I have also used
\DeclareMathOperator\appenc{\text{appenc}}
for yourappenc
as this looks bad above. You probably should do the same withSig
and perhaps others. My guess is that your notation can be improved, but it is easy to say this without knowing the full details:)Here is the full code: