我有以下代码
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{positioning,matrix}
\begin{document}
\begin{tikzpicture}[Dotted/.style={% https://tex.stackexchange.com/a/52856/194703
line width=1.2pt,
dash pattern=on 0.01\pgflinewidth off #1\pgflinewidth,line cap=round,
shorten >=0.3em,shorten <=0.3em},
Dotted/.default=5]
\matrix[matrix of math nodes,nodes={circle,draw,minimum size=1.5em},
column sep=2em,row sep=1ex](mat) {
C_1 & D_1 \\
C_2 & D_2 \\[2em]
C_m & D_n \\
};
\draw[Dotted] (mat-2-1) -- (mat-3-1);
\draw[Dotted] (mat-2-2) -- (mat-3-2);
\foreach \X in {1,2,3}
{\foreach \Y in {1,2,3}
{\draw (mat-\X-1) -- (mat-\Y-2);}}
\matrix[matrix of math nodes,nodes={circle,draw,minimum size=1.5em},
column sep=1em,below=2em of mat,xshift=2em,
column 2/.style={column sep=2.5em}](mat2) {
E_1 & E_2 & E_p\\
};
\draw[Dotted] (mat2-1-2) -- (mat2-1-3);
\end{tikzpicture}
不过我想在最后添加一组新节点。
问题是如果我使用\\
或\newline
我无法获取指向下一行的指针。
但是我无法进入新线路,有人可以帮忙吗?
答案1
在矩阵中添加一行就像添加类似的东西一样简单
F_1 & F_2 & F_p\\
代码:
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{positioning,matrix}
\begin{document}
\begin{tikzpicture}[Dotted/.style={% https://tex.stackexchange.com/a/52856/194703
line width=1.2pt,
dash pattern=on 0.01\pgflinewidth off #1\pgflinewidth,line cap=round,
shorten >=0.3em,shorten <=0.3em},
Dotted/.default=5]
\matrix[matrix of math nodes,nodes={circle,draw,minimum size=1.5em},
column sep=2em,row sep=1ex](mat) {
C_1 & D_1 \\
C_2 & D_2 \\[2em]
C_m & D_n \\
};
\draw[Dotted] (mat-2-1) -- (mat-3-1);
\draw[Dotted] (mat-2-2) -- (mat-3-2);
\foreach \X in {1,2,3}
{\foreach \Y in {1,2,3}
{\draw (mat-\X-1) -- (mat-\Y-2);}}
\matrix[matrix of math nodes,nodes={circle,draw,minimum size=1.5em},
column sep=1em,row sep=1em,below=2em of mat,xshift=2em,
column 2/.style={column sep=2.5em}](mat2) {
E_1 & E_2 & E_p\\
F_1 & F_2 & F_p\\
};
\foreach \X in {1,2}
{\draw[Dotted] (mat2-\X-2) -- (mat2-\X-3);}
\end{tikzpicture}
\end{document}