绘制简单的边,没有箭头

绘制简单的边,没有箭头

我有

\begin{tikzpicture}[->,auto,node distance=3cm,
  thick,main node/.style={draw,font=\bfseries}]
  \node[main node] (111) at (0,1) {$X_{1,1}^{(1)}$};
  \node[main node] (121) at (0,2) {$X_{1,2}^{(1)}$};
  \node[main node] (1n1) at (0,4) {$X_{1,n}^{(1)}$};
  \node[main node] (211) at (0,6) {$X_{2,1}^{(1)}$};
  \node[main node] (221) at (0,7) {$X_{2,2}^{(1)}$};
  \node[main node] (2n1) at (0,9) {$X_{2,n}^{(1)}$};
  \node[main node] (n11) at (0,11) {$X_{n,1}^{(1)}$};
  \node[main node] (n21) at (0,12) {$X_{n,2}^{(1)}$};
  \node[main node] (nn1) at (0,14) {$X_{n,n}^{(1)}$};
  \node[main node] (112) at (2.5,1) {$X_{1,1}^{(2)}$};
  \node[main node] (122) at (2.5,2) {$X_{1,2}^{(2)}$};
  \node[main node] (1n2) at (2.5,4) {$X_{1,n}^{(2)}$};
  \node[main node] (212) at (2.5,6) {$X_{2,1}^{(2)}$};
  \node[main node] (222) at (2.5,7) {$X_{2,2}^{(2)}$};
  \node[main node] (2n2) at (2.5,9) {$X_{2,n}^{(2)}$};
  \node[main node] (n12) at (2.5,11) {$X_{n,1}^{(2)}$};
  \node[main node] (n22) at (2.5,12) {$X_{n,2}^{(2)}$};
  \node[main node] (nn2) at (2.5,14) {$X_{n,n}^{(2)}$};
  \node[main node] (11k) at (6,1) {$X_{1,1}^{(k)}$};
  \node[main node] (12k) at (6,2) {$X_{1,2}^{(k)}$};
  \node[main node] (1nk) at (6,4) {$X_{1,n}^{(k)}$};
  \node[main node] (21k) at (6,6) {$X_{2,1}^{(k)}$};
  \node[main node] (22k) at (6,7) {$X_{2,2}^{(k)}$};
  \node[main node] (2nk) at (6,9) {$X_{2,n}^{(k)}$};
  \node[main node] (n1k) at (6,11) {$X_{n,1}^{(k)}$};
  \node[main node] (n2k) at (6,12) {$X_{n,2}^{(k)}$};
  \node[main node] (nnk) at (6,14) {$X_{n,n}^{(k)}$};
  \node[main node] (11n2) at (9.5,1) {$X_{1,1}^{(n-2)}$};
  \node[main node] (12n2) at (9.5,2) {$X_{1,2}^{(n-2)}$};
  \node[main node] (1nn2) at (9.5,4) {$X_{1,n}^{(n-2)}$};
  \node[main node] (21n2) at (9.5,6) {$X_{2,1}^{(n-2)}$};
  \node[main node] (22n2) at (9.5,7) {$X_{2,2}^{(n-2)}$};
  \node[main node] (2nn2) at (9.5,9) {$X_{2,n}^{(n-2)}$};
  \node[main node] (n1n2) at (9.5,11) {$X_{n,1}^{(n-2)}$};
  \node[main node] (n2n2) at (9.5,12) {$X_{n,2}^{(n-2)}$};
  \node[main node] (nnn2) at (9.5,14) {$X_{n,n}^{(n-2)}$};
  \node[main node] (11n1) at (12,1) {$X_{1,1}^{(n-1)}$};
  \node[main node] (12n1) at (12,2) {$X_{1,2}^{(n-1)}$};
  \node[main node] (1nn1) at (12,4) {$X_{1,n}^{(n-1)}$};
  \node[main node] (21n1) at (12,6) {$X_{2,1}^{(n-1)}$};
  \node[main node] (22n1) at (12,7) {$X_{2,2}^{(n-1)}$};
  \node[main node] (2nn1) at (12,9) {$X_{2,n}^{(n-1)}$};
  \node[main node] (n1n1) at (12,11) {$X_{n,1}^{(n-1)}$};
  \node[main node] (n2n1) at (12,12) {$X_{n,2}^{(n-1)}$};
  \node[main node] (nnn1) at (12,14) {$X_{n,n}^{(n-1)}$};
  \path
    (111) edge (112)
        edge (122)
        edge (1n2)
    (121) edge (112)
        edge (122)
        edge (1n2)
    (1n1) edge (112)
        edge (122)
        edge (1n2)
    (121) edge[--,dashed] (1n1);
\end{tikzpicture}

我只想要简单的线条,没有箭头。如何实现edge?谢谢

答案1

使用matrix节点来减少输入工作量也是有益的。我曾经使用一个小的 Excel 文件来删除节点名称并填充矩阵。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of math nodes, nodes={draw,font=\bfseries},row sep ={1cm,between origins},column sep={2cm,between origins}] (m) {
X_{n,n}^{(1)} &[0.5cm] X_{n,n}^{(2)} &[2cm] X_{n,n}^{(k)} &[1cm] X_{n,n}^{(n-2)} &[0.5cm] X_{n,n}^{(n-1)}\\[1cm]
X_{n,2}^{(1)} &        X_{n,2}^{(2)} &      X_{n,2}^{(k)} &      X_{n,2}^{(n-2)} &        X_{n,2}^{(n-1)}\\
X_{n,1}^{(1)} &        X_{n,1}^{(2)} &      X_{n,1}^{(k)} &      X_{n,1}^{(n-2)} &        X_{n,1}^{(n-1)}\\[1cm]
X_{2,n}^{(1)} &        X_{2,n}^{(2)} &      X_{2,n}^{(k)} &      X_{2,n}^{(n-2)} &        X_{2,n}^{(n-1)}\\[1cm]
X_{2,2}^{(1)} &        X_{2,2}^{(2)} &      X_{2,2}^{(k)} &      X_{2,2}^{(n-2)} &        X_{2,2}^{(n-1)}\\
X_{2,1}^{(1)} &        X_{2,1}^{(2)} &      X_{2,1}^{(k)} &      X_{2,1}^{(n-2)} &        X_{2,1}^{(n-1)}\\[1cm]
X_{1,n}^{(1)} &        X_{1,n}^{(2)} &      X_{1,n}^{(k)} &      X_{1,n}^{(n-2)} &        X_{1,n}^{(n-1)}\\[1cm]
X_{1,2}^{(1)} &        X_{1,2}^{(2)} &      X_{1,2}^{(k)} &      X_{1,2}^{(n-2)} &        X_{1,2}^{(n-1)}\\
X_{1,1}^{(1)} &        X_{1,1}^{(2)} &      X_{1,1}^{(k)} &      X_{1,1}^{(n-2)} &        X_{1,1}^{(n-1)}\\
};
  \path[thick]
    (m-7-1) edge (m-7-2)
        edge (m-8-2)
        edge (m-9-2)
    (m-8-1) edge (m-7-2)
        edge (m-8-2)
        edge (m-9-2)
    (m-9-1) edge (m-7-2)
        edge (m-8-2)
        edge (m-9-2)
    (m-7-1) edge[-,dashed] (m-8-1);
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

默认情况下没有箭头,但您使用以下参数edge为所有行打开了箭头:tikzpicture->

\begin{tikzpicture}[->,auto,node distance=3cm,
   thick,main node/.style={draw,font=\bfseries}]

移除->后就没有箭头了。

或者像杰克 (Jake) 所评论的那样,使用(或)-作为参数来本地删除箭头。\pathedge

\path[-]
(111) edge (112)
    edge (122)
    edge (1n2)
(121) edge (112)
    edge (122)
    edge (1n2)
(1n1) edge (112)
    edge (122)
    edge (1n2)
(121) edge[dashed] (1n1);

您还可以将\path绘制线条的功能放在环境中并使用相同的参数。如果您有多个想要应用此功能的/命令scope,那么这会很方便。\path\draw

\begin{scope}[-]
  \path
  (111) edge (112)
      edge (122)
      edge (1n2)
    (121) edge (112)
      edge (122)
      edge (1n2)
  (1n1) edge (112)
      edge (122)
       edge (1n2)
  (121) edge[dashed] (1n1);
\end{scope}

相关内容