gpt4 book ai didi

latex - Tikz:从节点绘制边到另一边的标签

转载 作者:行者123 更新时间:2023-12-01 09:27:42 31 4
gpt4 key购买 nike

我想弄清楚如何在 tikz 中的节点和其他两个节点之间的边缘标签之间绘制一条边。这是我正在尝试做的一个例子:
enter image description here

这是我的代码:

\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}

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

谢谢!

最佳答案

根据文档,

You may also add the option name=<name> to the option list; it has the same effect [as providing a node name with (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}

screenshot of output

关于latex - Tikz:从节点绘制边到另一边的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34236801/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com