6

我试图弄清楚如何在 tikz 中的节点和其他两个节点之间的边标签之间绘制一条边。这是我正在尝试做的一个例子: 在此处输入图像描述

这是我的代码:

\documentclass[11pt]{article}
\usepackage[margin=1in, top=1.5in]{geometry}
\usepackage{amsmath,amssymb,bbm}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows, positioning}

\setlength{\parindent}{0.25in}
\newcommand{\assign}{:=}
\usepackage[hang,small,bf]{caption}


\begin{document}

\begin{figure}[!h]
  \centering
  \begin{tikzpicture}[shorten >=1pt,node distance=3cm,on grid,auto]
    \tikzstyle{state}=[shape=circle,thick,draw,minimum size=1.5cm]

    \node[state] (A1) {$A_1$};
    \node[state,above of=A1] (B1) {$B_1$};
    \node[state,above of=B1] (C1) {$C_1$};

    \node[state,right of=A1] (A2) {$A_2$};
    \node[state,above of=A2] (B2) {$B_2$};
    \node[state,above of=B2] (C2) {$C_2$};



    \path[->,draw,thick]
    (A1) edge node {$l_A$} (B2)
    (B1) edge node {$l_B$} (B2)

    ;

  \end{tikzpicture}
  \caption{Model}
  \label{fig:f1}
\end{figure}


\end{document}

有人可以告诉我如何获得这种效果吗?

谢谢!

4

3 回答 3

6

根据文件,

您也可以将选项添加name=<name>option列表中;它具有相同的效果[作为提供节点名称与(name)]

以您的示例为例,这给出了:

\documentclass[11pt]{article}
\usepackage[margin=1in, top=1.5in]{geometry}
\usepackage{amsmath,amssymb,bbm}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows, positioning}

\setlength{\parindent}{0.25in}
\newcommand{\assign}{:=}
\usepackage[hang,small,bf]{caption}


\begin{document}

\begin{figure}[!h]
  \centering
  \begin{tikzpicture}[shorten >=1pt,node distance=3cm,on grid,auto]
    \tikzstyle{state}=[shape=circle,thick,draw,minimum size=1.5cm]

    \node[state] (A1) {$A_1$};
    \node[state,above of=A1] (B1) {$B_1$};
    \node[state,above of=B1] (C1) {$C_1$};

    \node[state,right of=A1] (A2) {$A_2$};
    \node[state,above of=A2] (B2) {$B_2$};
    \node[state,above of=B2] (C2) {$C_2$};



    \path[->,draw,thick]
    (A1) edge node[name=la] {$l_A$} (B2)
    (B1) edge node[name=lb] {$l_B$} (B2)

    ;
    \draw[->, thick, bend left=15]  (C1) edge (la) edge (lb); 

  \end{tikzpicture}
  \caption{Model}
  \label{fig:f1}
\end{figure}


\end{document}

输出截图

于 2019-01-22T10:51:23.670 回答
2

这个 TeX.SX 答案显示了如何将 apath从 a应用到node两个 ther 的中点node

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}[shorten >=1pt,node distance=3cm,auto]%,on grid
\tikzstyle{state}=[shape=circle,thick,draw,minimum size=1.5cm]

\node[state] (A1) {$A_1$};
\node[state,above of=A1] (B1) {$B_1$};
\node[state,above of=B1] (C1) {$C_1$};

\node[state,right of=A1] (A2) {$A_2$};
\node[state,above of=A2] (B2) {$B_2$};
\node[state,above of=B2] (C2) {$C_2$};

\path [->,draw,thick] (C1) -- ($ (B1) !.5! (B2) $);
\path [->,draw,thick] (C1) -- ($ (A1) !.5! (B2) $);

\path[->,draw,thick]
  (A1) edge node[near start] {$l_A$} (B2)
  (B1) edge node[near end] {$l_B$} (B2);

\end{tikzpicture}
\end{document}

输出截图

这只是一个粗略的起点:请发表评论,说明此草图是否合适,或者您是否想要进一步的开发。

于 2015-12-13T09:58:12.040 回答
1

回答那些可能会被它困住的人。

您需要创建辅助坐标并为它们画一条线(我正在使用 xetex)

% Preamble
\usepackage{tikz-uml}
\usetikzlibrary{positioning}
% Preamble end
...
\begin{tikzpicture}[shorten >=1pt,node distance=3cm,auto]%,on grid
\tikzstyle{state}=[shape=circle,thick,draw,minimum size=1.5cm]

  \node[state] (A1) {$A_1$};
  \node[state,above of=A1] (B1) {$B_1$};
  \node[state,above of=B1] (C1) {$C_1$};

  \node[state,right of=A1] (A2) {$A_2$};
  \node[state,above of=A2] (B2) {$B_2$};
  \node[state,above of=B2] (C2) {$C_2$};

  % Add Aux points
  \coordinate[yshift=0.6cm, right=1cm of B1.east] (aux1);
  \coordinate[yshift=1.6cm, right=0.1cm of A1.east] (aux2);

  % Your desired arrows
  \draw [arrow] (C1.east) to (aux1); % or (C1.east) -- (aux1) if you need multiple operations further
  % Below are three examples of a relatively same result
  \draw [arrow] (C1.south east) .. controls (1.4,3.5) .. (aux2);  
  % \draw [arrow] (C1.south east) to [bend left=24] (aux2);
  % \draw [arrow] (C1.south east) -| ([shift={(0.5cm,0cm)}]C1.south east) -- (aux2); % pointy arrow

  \path[->,draw,thick]
    (A1) edge node[near start] {$l_A$} (B2)
    (B1) edge node[near end] {$l_B$} (B2);

\end{tikzpicture}

在此处输入图像描述

于 2020-07-21T09:05:22.727 回答