2

How to make the label on the way of the draw?

Currently, my label "cross" the draws.

Here is my MWE:

\documentclass{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows,arrows.meta,
                backgrounds, bending,
                calc, chains,
                %decorations.pathmorphing,
                fit,
                %petri,
                positioning,
                trees,
                quotes,
                shapes.misc}

\definecolor{darkblue}{RGB}{31,22,70}
\definecolor{darkblue2}{RGB}{21,126,251}
\usepackage{graphicx}
\usepackage{float}
\begin{document}
   \begin{figure}[H]
        \centering
        \resizebox{\textwidth}{!}{
    \begin{tikzpicture}
        \coordinate (b) at (current page.center);
        \node[minimum height=1cm,minimum width=2cm,rounded corners,draw=white, fill=darkblue2!50,very thick,font=\sffamily\color{white}]at(b)(MQTT){MQTT};        
        \node[label={[name=1]above:\Large{Orchestrateur}},left=2 cm of MQTT](admin){\includegraphics[scale=0.8]{example-image-b}};
        \node[label={[name=1]above:\Large{Edge Node 1}},above right=of MQTT](node1){\includegraphics[scale=0.8]{example-image-b}};

        \node [label={[name=1]below:deviceTwin}]at(node1)(dt1){\includegraphics[scale=0.04]{example-image-a}};
        \node [label={[name=1]below:\Large{Edge Node 2}},below right=of MQTT](node2){\includegraphics[scale=0.8]{example-image-a}};
        \node [label={[name=1]below:deviceTwin}]at(node2)(dt2){\includegraphics[scale=0.04]{example-image-a}};
        \draw[arrows={-triangle 90}, darkblue, thick](admin)--node[above]{Publish}(MQTT);
        \draw[arrows={triangle 90-triangle 90}, darkblue, thick](MQTT)--node[above]{Publish/Subscribe}(dt1);

        \draw[arrows={triangle 90-triangle 90}, darkblue, thick](MQTT)--node[above]{Publish/Subscribe}(dt2);
    \end{tikzpicture}
    }
     \end{figure}
\end{document}

And the outputenter image description here

Thanks!

3

The option sloped seems to be what you are looking for. See a related post, you can simply use :

node[above, sloped] {Publish/Subscribe}

Your code with the applying options :

\documentclass{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows,arrows.meta,
                backgrounds, bending,
                calc, chains,
                %decorations.pathmorphing,
                fit,
                %petri,
                positioning,
                trees,
                quotes,
                shapes.misc}

\definecolor{darkblue}{RGB}{31,22,70}
\definecolor{darkblue2}{RGB}{21,126,251}
\usepackage{graphicx}
\usepackage{float}
\begin{document}
   \begin{figure}[H]
        \centering
        \resizebox{\textwidth}{!}{
    \begin{tikzpicture}
        \coordinate (b) at (current page.center);
        \node[minimum height=1cm,minimum width=2cm,rounded corners,draw=white, fill=darkblue2!50,very thick,font=\sffamily\color{white}]at(b)(MQTT){MQTT};        
        \node[label={[name=1]above:\Large{Orchestrateur}},left=2 cm of MQTT](admin){\includegraphics[scale=0.8]{example-image-b}};
        \node[label={[name=1]above:\Large{Edge Node 1}},above right=of MQTT](node1){\includegraphics[scale=0.8]{example-image-b}};

        \node [label={[name=1]below:deviceTwin}]at(node1)(dt1){\includegraphics[scale=0.04]{example-image-a}};
        \node [label={[name=1]below:\Large{Edge Node 2}},below right=of MQTT](node2){\includegraphics[scale=0.8]{example-image-a}};
        \node [label={[name=1]below:deviceTwin}]at(node2)(dt2){\includegraphics[scale=0.04]{example-image-a}};
        \draw[arrows={-triangle 90}, darkblue, thick](admin)--node[above]{Publish}(MQTT);
        \draw[arrows={triangle 90-triangle 90}, darkblue, thick](MQTT)--node[above, sloped]{Publish/Subscribe}(dt1);

        \draw[arrows={triangle 90-triangle 90}, darkblue, thick](MQTT)--node[above, sloped]{Publish/Subscribe}(dt2);
    \end{tikzpicture}
    }
     \end{figure}
\end{document}

and the corresponding output :

Output

  • My sincere compliments for your nice answer and for your contribute. – Sebastiano Jun 20 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.