1

Please consider the following picture:

Nodes design

I would like to create those nodes using the tikzpicture environment. Each must have a dividing line in the middle so that the node is divided into three sections (all contain numbers of up to 2 digits maximum). There are also some nodes that have a hyphen type arrow, which go to other nodes; these unions (with or without dots and with some text above the lines) must join or leave one of the left or right ends of the node, as you can see in the image.

Also, to make things easier, I hope that each node and each union will be available in an easy way, something like:

\begin{tikzpicture}
    \node at (0,0) (1) {1,0,0};
    \node at (1,-1) (2) {2,5,7};
    \node at (2,0) (3) {3,9,61};

    \draw (1) to [text=A(1)] (2) to [dotted] (3);
\end{tikzpicture}

(there are many more nodes and connections).

For the curious I am trying to imitate, with your huge hearts, the design of a Critical Path Method (CPM).

Thank you!!

EDIT:

Following the advice of Zarko and the example provided by Ignasi I created an MWE which generates 18 errors if I use the \usepackage[spanish]{babel} package (I need it, but this time I enclosed it to show you that the code works fine). How could I add this package that I need to the code?:

\documentclass{article}
%\usepackage[spanish]{babel}      % <-- HERE IS THE PACKAGE THAT I NEED
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tasks}
\usepackage{vmargin}
\usepackage{enumitem}
\usepackage{hhline}
\usepackage{pdflscape}

\setpapersize{A4}
\setmargins{2.2cm}
{0.5cm}
{16.5cm}
{23.42cm}
{30pt}
{1cm}
{0pt}
{2cm}
\pagestyle{fancy}
\fancyhf{}
\cfoot{\large \thepage}
\renewcommand{\headrulewidth}{0pt}

\usepackage{colortbl}

\usepackage{pgfplots}
\usetikzlibrary{shapes.multipart, positioning}
\pgfplotsset{compat=1.8}

\begin{document}

\begin{tikzpicture}[
    trinode/.style={
    circle split,
    draw,
    path picture={\draw (path picture bounding box.center)--(path picture bounding box.south);}}
    ]

    %\node[trinode] (1) {99\nodepart{lower} 99\ \ 99};
    \node[trinode] at (0,0) (1) {99\nodepart{lower} 99\ \ 99};

    %\node[trinode, below right=of 1] (2) {99\nodepart{lower} 99\ \ 99};
    \node[trinode] at (2,-2) (2) {99\nodepart{lower} 99\ \ 99};

    %\node[trinode, above right=of 2] (3) {99\nodepart{lower} 99\ \ 99};
    \node[trinode] at (4,0) (3) {99\nodepart{lower} 99\ \ 99};

    \draw[->] (1)--(2) node[midway, right] {A(1)};
    \draw[->,dashed] (2)--(3);
\end{tikzpicture}

\end{document}
manooooh
  • 3,203
  • 2
  • 21
  • 46
  • 2
    please make your code snippet compilable small document. – Zarko Jul 09 '18 at 08:15
  • Hi @Zarko. I am sorry but no MWE created because it is focused on your imagination of code! Using article document and tikzpicture environment (with some libraries, like arrow) I think it's all you need. If this is not sufficient let me know. – manooooh Jul 09 '18 at 08:23
  • 3
    oh, thank you very much for your concern for my imagination :-). however, you should provide complete document. if you do so, i or anyone else still be able to express imagination ... – Zarko Jul 09 '18 at 09:01
  • @Zarko please see edit. – manooooh Jul 09 '18 at 19:39
  • well, meantime you got nice answer. see my comment below it. – Zarko Jul 09 '18 at 19:50

1 Answers1

4

I've seen this kind of nodes somewhere in TeX.SX but as I don't know who to search them I provide a solution with a circle split.

These nodes uses two texts upper and lower separated by an horizontal line. My solution declares two lower numbers as a common text and the path picture command draws the vertical line.

Connections between nodes and labels for paths are the usual ones.

\documentclass[tikz,border=2mm]{standalone}

\usetikzlibrary{babel, positioning, shapes.multipart}

\begin{document}

\begin{tikzpicture}[
    trinode/.style={
            circle split,
            draw,
            path picture={\draw (path picture bounding box.center)--(path picture bounding box.south);}}]

\node[trinode] (1) {99\nodepart{lower} 99\ \ 99};

\node[trinode, below right=of 1] (2) {99\nodepart{lower} 99\ \ 99};

\node[trinode, above right=of 2] (3) {99\nodepart{lower} 99\ \ 99};

\draw[->] (1)--(2) node[midway, right]{A(1)};
\draw[->,dashed] (2)--(3);
\end{tikzpicture}
\end{document}

enter image description here

Zarko
  • 296,517
Ignasi
  • 136,588
  • 2
    This one? https://tex.stackexchange.com/questions/58993/how-create-circle-node-in-tikz-with-t-from-lines-inside-t-made-split-node-to-3 – percusse Jul 09 '18 at 10:47
  • It looks awesome @Ignasi! However if I load a package (specifically the \usepackage[spanish]{babel}) it generates 18 errors. Please consider the MWE in my edit. – manooooh Jul 09 '18 at 19:40
  • 1
    @manooooh, you need to add totikz librarybabel, i.e.; \usetikzlibrary{shapes.multipart, positioning, babel} – Zarko Jul 09 '18 at 19:49
  • @Zarko it works, but this includes the spanish version? – manooooh Jul 09 '18 at 19:52
  • actually not. in tikzpicture it restore original meaning of all characters which are changed by babel package with many language option (spanish, french, ... and also slovene). – Zarko Jul 09 '18 at 19:56
  • @Zarko ok, so the answer is yes. Thank you! (Are you slovene..? O.o :D) – manooooh Jul 09 '18 at 19:57
  • i took liberty and add tikz library babel. – Zarko Jul 09 '18 at 19:59
  • @manooooh, i usually live in slovenia (temporary not) ... in slovene is my native language. – Zarko Jul 09 '18 at 20:02
  • @Zarko I accept the edit. This site is multicultural! Hvala! – manooooh Jul 09 '18 at 20:05
  • @Ignasi is there any way that all the nodes have the same size? Because if I create a node with one digit in each section and another with two digits, the sizes of both nodes are different. – manooooh Jul 10 '18 at 00:38
  • 1
    @manooooh: yes. fix a minimum size large enough for two digits and it will be keeped on one digit nodes. – Ignasi Jul 10 '18 at 06:37
  • @Ignasi sorry for the late response. I tried it but it doesn't change anything. I tried 3 ways (all inside the tikzpicture environment): \begin{tikzpicture}[node/.style={minimum size=5mm},..., or trinode/.style={minimum size=5mm, circle split, ... or \begin{tikzpicture}[minimum size=5mm,trinode/.style={... (I use 5mm but I don't know if this measure is OK). What's wrong? Could you edit your message adding these, please? Thanks – manooooh Jul 11 '18 at 16:25
  • 1
    @manooooh the second option is the correct one, but 5mm is to short. Try without minimum size but two digit numbers. View the result at 100% and neasure the node. Try with this value as minimum size and see what happens. – Ignasi Jul 11 '18 at 17:33
  • It worked 101%! Have you been born reading a LaTeX guide or what? :'D – manooooh Jul 12 '18 at 00:16