0

I'm trying to create diagrams like the ones in the following picture in TikZ (I've included a few different examples). Currently I manually shift the nodes along the x-axis to make it somewhat fit, but this obviously doesn't work very well. Besides trying out different values until it kind of works being effort, the nodes aren't even aligned properly. The last example shows this very well (a_0 and a_n should be above b_0 and b_n respectively).

Example 1

Example 2

Example 3

Example 4

Example 5

This is my current approach, MWE for the provided examples:

\documentclass[tikz]{standalone}

\begin{document}
    \begin{tikzpicture}
        \node (a) at (0, 0) {$(p, \bar{u}) = c_1$};
        \node[rotate=90] (leq1) at (0.6, -0.35) {$\leq$};
        \node (b) at (1.2, -0.7) {$(p, \bar{u}') = c_1' \longrightarrow c_2' = (q, \bar{v}')$};
        \node[rotate=90] (leq2) at (1.7, -1.05) {$\leq$};
        \node (c) at (2.4, -1.4) {$c_2 = (q, \bar{v})$};
    \end{tikzpicture}

    \begin{tikzpicture}
        \node (a) at (0, 0) {$(p, \bar{v})$};
        \node[rotate=90] (leq1) at (0, -0.35) {$\leq$};
        \node (b) at (0.9, -0.7) {$(p, \bar{v}') \longrightarrow (q, \bar{w}')$};
        \node[rotate=90] (leq2) at (1.7, -1.05) {$\leq$};
        \node (c) at (1.7, -1.4) {$(q, \bar{w})$};
    \end{tikzpicture}

    \begin{tikzpicture}
        \node (a) at (0, 0) {$(p, u)$};
        \node[rotate=90] (leq1) at (0, -0.35) {$\leq$};
        \node (b) at (-0.3, -0.7) {$A \ni (p, u')$};
        \node[rotate=90] (leq2) at (0, -1.05) {$\leq$};
        \node (c) at (0, -1.4) {$(p, u'')$};
        \node[rotate=90] (leq2) at (0, -1.75) {$\leq$};
        \node (d) at (0.75, -2.1) {$B \ni (p, u''') \longrightarrow (q, v) \in C$};
    \end{tikzpicture}

    \begin{tikzpicture}
        \node (a) at (0, 0) {$\circ \longrightarrow^* \circ$};
        \node[rotate=90] (leq1) at (-0.5, -0.35) {$\leq$};
        \node[rotate=90] (leq2) at (0.5, -0.35) {$\leq$};
        \node (b) at (0.5, -0.7) {$\circ \longrightarrow \circ \longrightarrow^* \circ$};
        \node[rotate=90] (leq3) at (1.5, -1.05) {$\leq$};
        \node (c) at (1.9, -1.4) {$\circ \in A$};
    \end{tikzpicture}

    \begin{tikzpicture}
        \node (a) at (0, 0) {$a = a_0 \longrightarrow^* a_1 \longrightarrow^* a_2 \longrightarrow^* \ldots \longrightarrow^* a_n$};
        \node[rotate=90] (leq1) at (-2.1, -0.35) {$\leq$};
        \node[rotate=90] (leq2) at (2.6, -0.35) {$\leq$};
        \node (b) at (0, -0.7) {$b = b_0 \longrightarrow b_1 \longrightarrow b_2 \longrightarrow \ldots \longrightarrow b_n$};
    \end{tikzpicture}
\end{document}

How can I create these kinds of diagrams properly?

Simon
  • 171

2 Answers2

1

Why you need to draw this equations? It seems that is more simple to write them as arrays. For example for your last two examples in question:

\documentclass{article}
\usepackage{adjustbox}

\begin{document}
\[\setlength\arraycolsep{1pt}
    \begin{array}{ccc cccc c}
\circ   & \longrightarrow^*             & \circ                         &   &   &   &   \\
\adjustbox{rotate=90}{$\leq$} 
        &   & \adjustbox{rotate=90}{$\leq$}                             &   &   &   &   \\
\circ   & \longrightarrow^*             & \circ                         
        & \longrightarrow^*             & \circ                                 &   &   \\
        &   &   &   & \adjustbox{rotate=90}{$\leq$}                     &   &   &   &   \\
        &   &   &   & \circ             & \in  &  A     \\
    \end{array}
\]
\bigskip
\[\setlength\arraycolsep{1pt}
    \begin{array}{rclcl clcl cl}
a   & = & a_0                     
    & \longrightarrow^* & a_1    & \longrightarrow^* & a_2
    & \longrightarrow^* & \ldots & \longrightarrow^* & a_n  \\
    && \adjustbox{rotate=90}{$\leq$} && &&&& && \adjustbox{rotate=90}{$\leq$}  \\
b   & = & b_0 
    & \longrightarrow   & b_1    & \longrightarrow   & b_2
    & \longrightarrow   & \ldots & \longrightarrow   & b_n
    \end{array}
\]
\end{document}

enter image description here

If you for some reason like to have those arrays in tikz picture, than you only need to inserte them in nodes' contents:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{adjustbox}

\begin{document}
    \begin{tikzpicture}[node distance=2mm and 0mm,
                        every node/.style = {fill=cyan!15}
                        ]
    \setlength\arraycolsep{1pt}
\node (n1) {$\begin{array}{ccc ccc c}
\circ   & \longrightarrow^*             & \circ                         &   &   &   &   \\
\adjustbox{rotate=90}{$\leq$}
        &   & \adjustbox{rotate=90}{$\leq$}                             &   &   &   &   \\
\circ   & \longrightarrow^*             & \circ
        & \longrightarrow^*             & \circ                                 &   &   \\
        &   &   &   & \adjustbox{rotate=90}{$\leq$}                             &   &   \\
        &   &   &   & \circ             & \in                                       &  A
    \end{array}$};
\node (n2) [below right=of n1.south west]
        {$\begin{array}{rclcl clcl cl}
a   & = & a_0
    & \longrightarrow^* & a_1    & \longrightarrow^* & a_2
    & \longrightarrow^* & \ldots & \longrightarrow^* & a_n  \\
    && \adjustbox{rotate=90}{$\leq$} && &&&& && \adjustbox{rotate=90}{$\leq$}  \\
b   & = & b_0
    & \longrightarrow   & b_1    & \longrightarrow   & b_2
    & \longrightarrow   & \ldots & \longrightarrow   & b_n
        \end{array}$};
    \end{tikzpicture}
\end{document}

(for better seeing of nodes the fill=cyan!15 is added to nodes' style)

enter image description here

Zarko
  • 296,517
0

Such diagrams can be done very conveniently with tikz-cd. The arrow with the star is from here. The rotated \ge signs can be obtained with \arrow[d,draw=none,"\ge" marking].

\documentclass{article}
\usepackage{tikz-cd}
\usepackage{mathtools}
\usetikzlibrary{arrows.meta}

\newcommand{\mysym}{\vphantom{\to}^{*}}

\begin{document}

\tikzset{% https://tex.stackexchange.com/a/492664
startip/.tip={Glyph[glyph math command=mysym]},
Rightarrow*/.style={double equal sign distance,>={Implies},->.startip},
to*/.style={->.startip}}
%Diagram 1
\begin{tikzcd}[cramped,row sep=0.8em,every label/.style={font=\normalsize}]
|[label={[xshift=4pt]left:(p, \bar{u})=}]| c_1 
\arrow[d,draw=none,"\ge" marking] & \\
|[label={[xshift=4pt]left:(p, \bar{u}')=}]| c_1' \arrow[r]
 & |[label={[xshift=-4pt]right:= (q, \bar{v}')}]| c_2' 
\arrow[d,draw=none,"\ge" marking]  \\
& |[label={[xshift=-4pt]right:= (q, \bar{v})}]| c_2 \\
\end{tikzcd}
\bigskip


%Diagram 2
\begin{tikzcd}[cramped,row sep=0.8em,every label/.style={font=\normalsize}]
   (p,\bar v)\arrow[d,draw=none,"\ge" marking]  & \\
   (p,\bar v) \arrow[r]& (q,\bar w')\arrow[d,draw=none,"\ge" marking] \\
   & (q,\bar w) \\
\end{tikzcd}
\bigskip

%Diagram 3
\begin{tikzcd}[cramped,row sep=0.8em,every label/.style={font=\normalsize}]
   (p,u)\arrow[d,draw=none,"\ge" marking]  & \\
   |[label={[xshift=4pt]left:A\ni}]|(p,u')\arrow[d,draw=none,"\ge" marking]  & \\
   (p,u'')\arrow[d,draw=none,"\ge" marking]  & \\
   |[label={[xshift=4pt]left:B\ni}]|(p,u''')\arrow[r]&
   (q,v)\in C\\
\end{tikzcd}
\bigskip

%Diagram 4
\begin{tikzcd}[cramped,row sep=0.8em,every label/.style={font=\normalsize}]
   \circ\arrow[r,to*]\arrow[d,draw=none,"\ge" marking]  &
   \circ\arrow[d,draw=none,"\ge" marking] &\\
   \circ \arrow[r] & \circ \arrow[r,to*] & \circ\arrow[d,draw=none,"\ge" marking]\\
   & & \circ \mathrlap{\,\in A}\\
\end{tikzcd}
\bigskip

%Diagram 5
\begin{tikzcd}[cramped,row sep=0.8em,every label/.style={font=\normalsize}]
    |[label={[xshift=4pt]left:a=}]|a_0 \arrow[d,draw=none,"\ge" marking]\arrow[r,to*] & a_1 \arrow[r,to*] & a_2 \arrow[r,to*] 
        &\dots \arrow[r,to*]& a_n\arrow[d,draw=none,"\ge" marking] \\
    |[label={[xshift=4pt]left:b=}]|b_0 \arrow[r,to*] & b_1 \arrow[r,to*] & b_2 \arrow[r,to*] 
        &\dots \arrow[r,to*]& b_n \\
\end{tikzcd}
\end{document}

enter image description here