我想画一些类似的东西
在 LaTeX 中。
我是 LaTeX 新手,不知道如何绘制。我该怎么办?
答案1
一种可能性是使用TikZ
;使用循环放置和命名一些圆形节点\foreach
,然后使用以下语法绘制箭头(<name>.<angle>)
:
代码:
\documentclass[tikz,border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{
mycircle/.style={
circle,
draw,
inner sep=5pt
}
}
\begin{document}
\begin{tikzpicture}[>=latex]
\foreach \Valor/\Texto in {1/$7$,2/$11$,3/$18$,4/$12$}
\node[mycircle,label={left:\Texto}] at (0,-\Valor cm) (column\Valor) {};
\foreach \Valor/\Texto in {1/$-10$,2/$-23$,3/$-15$}
\node[mycircle,label={above:\Texto}] at (\Valor cm,1cm) (row\Valor) {};
\node[above right=5pt and 20pt of row3] {Demands};
\node[below=5pt and 20pt of column4] {Supplies};
\draw[->]
(column1.20) -| (row1.-110) node[midway,above left] {$5$};
\draw[->]
(column1.-20) -| (row2.-140) node[midway,above left] {$6$};
\draw[->]
(column2.20) -| (row1.-70) node[midway,above left] {$8$};
\draw[->]
(column2.0) -| (row2.-110) node[midway,above left] {$4$};
\draw[->]
(column2.-20) -| (row3.-110) node[midway,above left] {$3$};
\draw[->]
(column3) -| (row2.-70) node[midway,above left] {$9$};
\draw[->]
(column4.20) -| (row2.-40) node[midway,above left] {$3$};
\draw[->]
(column4.-20) -| (row3.-70) node[midway,above left] {6};
\end{tikzpicture}
\end{document}