沿箭头用文本框绘制图形

沿箭头用文本框绘制图形

对于这个图,我使用 Word 和 Mathtype 来绘制,但输出效果不太好。我如何在 LaTeX 中绘制?我刚开始使用 TikZ 打包,但我想它的强大功能可以在这里帮助我?在此处输入图片描述

答案1

尝试快速简单地完成此操作:

\documentclass[tikz]{standalone}

\begin{document}
\tikzset{mybox/.style={draw},myarrow/.style={blue,->},myformula/.style={midway,sloped,draw,black,outer sep=4pt}}
\begin{tikzpicture}
\node[mybox](Z) at (0,0) {Z};
\node[mybox](X) at (4,2) {X};
\node[mybox](Y) at (4,-2) {Y};

\node[anchor=east] at (Z.west) {B};
\node[anchor=west] at (X.east) {A};
\node[anchor=west] at (Y.east) {C};

\draw[myarrow] (Z) -- (X) node[myformula,above]{$\lambda_1=-1.115$};
\draw[myarrow] (X) -- (Y) node[myformula,above]{$\lambda_2=-8.273$};
\draw[myarrow] (Z) -- (Y) node[myformula,below]{$\lambda_3=13.232$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

tabular这在简单的环境中很容易获得pstricks

\documentclass[svgnames]{article}
\usepackage{array}
\usepackage{upgreek}
\usepackage{pst-node}


\begin{document}

{\renewcommand{\arraystretch}{4}\centering \begin{tabular}{c!{\qquad}c!{\qquad}c}
                & & \psDefBoxNodes{X}{\fbox{X}}\enspace A\\
              B\qquad \psDefBoxNodes{Z}{\fbox{Z}}& & \\
               & & \psDefBoxNodes{Y}{\fbox{Y}}\enspace C
            \end{tabular}
\psset{arrowinset = 0, arrows =->, linecolor=LightBlue, nodesep=3pt, nrot=:U}
\ncline{Z:Cr}{X:Cl}\naput{\fbox{$\uplambda_1=-1.115$}}
\ncline{Z:Cr}{Y:Cl}\nbput{\fbox{$\uplambda_3=-13.232$}}
\ncline{X:bC}{Y:tC}\naput{\fbox{$\uplambda_2=-8.273$}}
}

\end{document} 

在此处输入图片描述

答案3

使用库arrows.metaquotes

\documentclass[border=3.141592, tikz]{standalone}
\usetikzlibrary{arrows.meta,
                quotes}

\begin{document}
    \begin{tikzpicture}[
every edge quotes/.style = {auto, draw=black, thin,
                            inner sep=2pt, outer sep=2pt, sloped},
                        ]
\scoped[nodes={draw, outer sep=2pt}]%
{
\node[label=left:B] (Z) at (0, 0) {Z};
\node[label=right:A](X) at (4, 2) {X};
\node[label=right:C](Y) at (4,-2) {Y};
}
\path[draw=cyan, thick, -Straight Barb] 
    (Z) edge["$\lambda_1=-1.115$"]  (X)
    (X) edge["$\lambda_2=-8.273$"]  (Y)
    (Z) edge["$\lambda_3=13.232$" '](Y);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容