同一矩阵节点中的两个标签

同一矩阵节点中的两个标签

我想在同一个矩阵节点中标记两个对象(两个角色),这样就可以从上面的节点向下层节点中的每个对象绘制一个箭头。更准确地说,我想从 到 绘制一个箭头,|(C3)| C\textsubscript{3}|(c3)| \textipa{n}到 绘制一个箭头|(C3)| C\textsubscript{3}|(c3)| \textcolor{Gray}{\textipa{g}}这里有代码。你能帮帮我吗?

    \begin{tikzpicture} 
    \matrix [matrix of nodes, row sep=0.75em, column sep={2em,between origins}, row 3/.style={font=\scshape}] 
{ 
|(C1)| C\textsubscript{1}   & |(V1)| \textcolor{Gray}{V\textsubscript{1}}   & |(C2)| C\textsubscript{2} & |(V2)| V\textsubscript{2} & |(C3)| C\textsubscript{3} & |(V3)| V\textsubscript{3}     \\
|(c1)| \textipa{t}          &                           & |(c2)| \textcolor{Gray}{\textipa{j}}      & |(v2)| \textipa{E}        & |(c3)| \textipa{n} \textcolor{Gray}{\textipa{g}}      &                                               \\
}; 
 
\draw [<->] (C1) to (c1); 
\draw [->][color=Gray] (C2) to (c2); 
\draw [<->] (V2) to (v2);
\draw [<->] (C3) to (c3);

\draw [<->] (c2) to (c1);

    \end{tikzpicture}   

答案1

我猜你正在经历这样的事情:

在此处输入图片描述

使用以下包绘制图像tikz-cd


\documentclass[border=3.141592]{standalone}
\usepackage[dvipsnames, table]{xcolor}
\usepackage{tikz-cd}

\begin{document}
    \begin{tikzcd}[cells={nodes={inner sep=1pt}},
                   column sep=tiny, 
                   arrows=<->, >={Straight Barb[scale=0.8]},
                  ]
C_1  \ar[d] &|[text=Gray]| V_1  
                & C_2 \ar[d]  
                    & V_2 \ar[d,->] 
                            & C_3 \ar[d,start anchor=250, end anchor={[xshift=-1ex]north}]
                                  \ar[d,gray,
                                        start anchor=290, end anchor={[xshift=+1ex]north}]
                                &  V_3    \\
t \ar[rr]   &   &|[text=Gray]| j     
                    & E     & {n}\; \textcolor{Gray}{g}    
                                &  
    \end{tikzcd} 
\end{document}

答案2

另一个解决方案是保留matrix of nodes。您可以使用基于节点周围角度的锚点(例如\draw [<->] (C3.250) to (c3.120);),或者使用预定义的锚点,如\draw [<->] (C3.south) to ($(c3.north)!.5!(c3.north east)$);。当然,您可以更改我设置的值!

\documentclass{report}
\usepackage{xcolor}
\usepackage{tipa}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning,calc}
\begin{document}
    \begin{tikzpicture} 
    \matrix [matrix of nodes, row sep=0.75em, column sep={2em,between origins}, row 3/.style={font=\scshape}] 
    { 
        |(C1)| C\textsubscript{1}   & |(V1)| \textcolor{gray}{V\textsubscript{1}}   & |(C2)| C\textsubscript{2} & |(V2)| V\textsubscript{2} & |(C3)| C\textsubscript{3} & |(V3)| V\textsubscript{3}     \\
        |(c1)| \textipa{t}          &                           & |(c2)| \textcolor{gray}{\textipa{j}}      & |(v2)| \textipa{E}        & |(c3)| \textipa{n} \textcolor{gray}{\textipa{g}}      &                                               \\
    }; 
    
    \draw [<->] (C1) to (c1); 
    \draw [->, color=gray] (C2) to (c2); 
    \draw [<->] (V2) to (v2);
    \draw [<->] (C3.250) to (c3.120);
    \draw [<->, gray] (C3.south) to ($(c3.north)!.5!(c3.north east)$);
    
    \draw [<->] (c2) to (c1);
    
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容