过渡系统中节点的对齐

过渡系统中节点的对齐

我正在尝试在 TikZ 中创建如下图所示的图表(我提供了几个不同的示例)。目前,我手动沿 x 轴移动节点以使其稍微适合,但这显然效果不佳。除了尝试不同的值直到它有点努力工作之外,节点甚至没有正确对齐。最后一个例子很好地说明了这一点(a_0a_n应该分别在b_0b_n上方)。

示例 1

示例 2

示例 3

示例 4

示例 5

这是我当前的方法,针对所提供示例的 MWE:

\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}

我如何才能正确创建这些类型的图表?

答案1

为什么需要画出这些方程式?把它们写成数组似乎更简单。例如,对于你最后两个例子:

\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}

在此处输入图片描述

如果您出于某种原因喜欢在图片中拥有这些数组tikz,那么您只需要将它们插入到节点的内容中:

\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}

(为了更好地查看节点,fill=cyan!15将其添加到节点样式中)

在此处输入图片描述

答案2

此类图表可以非常方便地使用 来绘制tikz-cd。带星号的箭头来自这里.\ge可以使用 获得旋转的符号\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}

在此处输入图片描述

相关内容