将节点中的数学拆分成两行

将节点中的数学拆分成两行

我有以下代码:

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{calc}
\tikzset{cross/.style={cross out, draw=black,ultra thick, minimum size=3*(#1-\pgflinewidth), inner sep=0pt, outer sep=0pt},
%default radius will be 1pt. 
cross/.default={3pt}}
\usetikzlibrary{decorations.pathreplacing}

\tikzset{
    ncbar angle/.initial=90,
    ncbar/.style={
        to path=(\tikztostart)
        -- ($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)
        -- ($(\tikztotarget)!($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztostart)$)
        -- (\tikztotarget)
    },
    ncbar/.default=0.5cm,
}
\tikzset{square right brace/.style={ncbar=-0.5cm}}

\begin{document}

\begin{tikzpicture}
  %[scale=1,auto=left,thick,every node/.style={circle,fill=green!50}]
    \node (n_s1) at (0,6) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{S}$};
    \node (n_t1) at (0,0) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{T}$};  
    \node (n1) at (0,3) [draw=red,scale=0.7,thick,circle,fill=green] {$x_a$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n_s1)--(n1) node [pos=0.5,left,font=\footnotesize] {$\theta_{a;0}$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n1)--(n_t1) node [pos=0.5,left,font=\footnotesize] {$\theta_{a;1}$};  

    \draw (1.5,3) node[cross=4,rotate=45]{};  

    \node (n_s2) at (3,6) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{S}$};
    \node (n_t2) at (3,0) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{T}$};  
    \node (n2) at (3,3) [draw=red,scale=0.7,thick,circle,fill=green] {$x_b$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n_s2)--(n2) node [pos=0.5,left,font=\footnotesize] {$\theta_{b;0}$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n2)--(n_t2) node [pos=0.5,left,font=\footnotesize] {$\theta_{b;1}$};  

    \draw (4.5,3) node[cross=4,rotate=45]{};  

    \node (n_s3) at (7.5,6) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{S}$};
    \node (n_t3) at (7.5,0) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{T}$};  
    \node (n31) at (6,3) [draw=red,scale=0.7,thick,circle,fill=green] {$x_a$};
    \node (n32) at (9,3) [draw=red,scale=0.7,thick,circle,fill=green] {$x_b$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n_s3)--(n31) node [pos=0.5,left,font=\footnotesize] {$\theta_{b;0}$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n32)--(n_t3) node [pos=0.5,right,font=\footnotesize] {$\theta_{b;1}$};   
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n31.10)--(n31.10-|n32.west) node [pos=0.5,above,font=\footnotesize] {$\theta_{ab;10}$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n32.-170)--(n32.-170-|n31.east) node [pos=0.5,below,font=\footnotesize] 
    {$\theta_{ab;01} - \theta_{ab;00} - \theta_{ab;11}$}; 

    \draw [black, ultra thick] (9.5,0) to [square right brace] (9.5,6);

    \node (n_s4) at (13.5,6) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{S}$};
    \node (n_t4) at (13.5,0) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{T}$};  
    \node (n41) at (12,3) [draw=red,scale=0.7,thick,circle,fill=green] {$x_a$};
    \node (n42) at (15,3) [draw=red,scale=0.7,thick,circle,fill=green] {$x_b$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n_s4)--(n41) node [pos=0.5,left,font=\footnotesize] {$w_1$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n_s4)--(n42) node [pos=0.5,right,font=\footnotesize] {$w_3$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n41)--(n_t4) node [pos=0.5,left,font=\footnotesize] {$w_2$};  
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n42)--(n_t4) node [pos=0.5,right,font=\footnotesize] {$w_4$};   
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n41.10)--(n41.10-|n42.west) node [pos=0.5,above,font=\footnotesize] {$w_5$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n42.-170)--(n42.-170-|n41.east) node [pos=0.5,below,font=\footnotesize] {$w_6$};         

    \draw[ultra thick,->,shorten >=20pt,shorten <=21pt] (n32)--(n41);

\end{tikzpicture}

\end{document}

我想将其分成$\theta_{ab;01} - \theta_{ab;00} - \theta_{ab;11}$两行,这样就$- \theta_{ab;11}$在下面$- \theta_{ab;00}$

答案1

像这样 ?

\documentclass[border=2mm]{standalone}
\usepackage{tikz,mathtools}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{calc}
\tikzset{cross/.style={cross out, draw=black,ultra thick, minimum size=3*(#1-\pgflinewidth), inner sep=0pt, outer sep=0pt},
%default radius will be 1pt.
cross/.default={3pt}}
\usetikzlibrary{decorations.pathreplacing}

\tikzset{
    ncbar angle/.initial=90,
    ncbar/.style={
        to path=(\tikztostart)
        -- ($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)
        -- ($(\tikztotarget)!($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztostart)$)
        -- (\tikztotarget)
    },
    ncbar/.default=0.5cm,
}
\tikzset{square right brace/.style={ncbar=-0.5cm}}

\begin{document}

\begin{tikzpicture}
  %[scale=1,auto=left,thick,every node/.style={circle,fill=green!50}]
    \node (n_s1) at (0,6) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{S}$};
    \node (n_t1) at (0,0) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{T}$};
    \node (n1) at (0,3) [draw=red,scale=0.7,thick,circle,fill=green] {$x_a$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n_s1)--(n1) node [pos=0.5,left,font=\footnotesize] {$\theta_{a;0}$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n1)--(n_t1) node [pos=0.5,left,font=\footnotesize] {$\theta_{a;1}$};

    \draw (1.5,3) node[cross=4,rotate=45]{};

    \node (n_s2) at (3,6) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{S}$};
    \node (n_t2) at (3,0) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{T}$};
    \node (n2) at (3,3) [draw=red,scale=0.7,thick,circle,fill=green] {$x_b$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n_s2)--(n2) node [pos=0.5,left,font=\footnotesize] {$\theta_{b;0}$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n2)--(n_t2) node [pos=0.5,left,font=\footnotesize] {$\theta_{b;1}$};

    \draw (4.5,3) node[cross=4,rotate=45]{};

    \node (n_s3) at (7.5,6) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{S}$};
    \node (n_t3) at (7.5,0) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{T}$};
    \node (n31) at (6,3) [draw=red,scale=0.7,thick,circle,fill=green] {$x_a$};
    \node (n32) at (9,3) [draw=red,scale=0.7,thick,circle,fill=green] {$x_b$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n_s3)--(n31) node [pos=0.5,left,font=\footnotesize] {$\theta_{b;0}$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n32)--(n_t3) node [pos=0.5,right,font=\footnotesize] {$\theta_{b;1}$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n31.10)--(n31.10-|n32.west) node [pos=0.5,above,font=\footnotesize] {$\theta_{ab;10}$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n32.-170)--(n32.-170-|n31.east) node [pos=0.5,below,font=\footnotesize]
    {$\begin{aligned}
    \theta_{ab;01} &- \theta_{ab;00}\\ 
                   &- \theta_{ab;11}
    \end{aligned}$};

    \draw [black, ultra thick] (9.5,0) to [square right brace] (9.5,6);

    \node (n_s4) at (13.5,6) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{S}$};
    \node (n_t4) at (13.5,0) [draw=red,scale=1,thick,circle,fill=gray!50] {$\mathbf{T}$};
    \node (n41) at (12,3) [draw=red,scale=0.7,thick,circle,fill=green] {$x_a$};
    \node (n42) at (15,3) [draw=red,scale=0.7,thick,circle,fill=green] {$x_b$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n_s4)--(n41) node [pos=0.5,left,font=\footnotesize] {$w_1$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n_s4)--(n42) node [pos=0.5,right,font=\footnotesize] {$w_3$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n41)--(n_t4) node [pos=0.5,left,font=\footnotesize] {$w_2$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n42)--(n_t4) node [pos=0.5,right,font=\footnotesize] {$w_4$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n41.10)--(n41.10-|n42.west) node [pos=0.5,above,font=\footnotesize] {$w_5$};
    \draw[-latex,shorten >=5pt,shorten <=5pt] (n42.-170)--(n42.-170-|n41.east) node [pos=0.5,below,font=\footnotesize] {$w_6$};

    \draw[ultra thick,->,shorten >=20pt,shorten <=21pt] (n32)--(n41);

\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容