如何在tikz latex中的顶点中添加下标?

如何在tikz latex中的顶点中添加下标?,latex,tikz,Latex,Tikz,我面临的问题是,我可以为每个顶点定义标签,但当我移动到顶点的南部或东部时,这只会创建一个新的顶点 \begin{figure} \tikzstyle{VertexStyle} = [shape = ellipse,minimum width= 6ex,draw] \tikzstyle{EdgeStyle} = [->,>=stealth'] \begin{tikzpicture}[scale=0.5, auto=left,every node/.style={circ

我面临的问题是,我可以为每个顶点定义标签,但当我移动到顶点的南部或东部时,这只会创建一个新的顶点

\begin{figure}
\tikzstyle{VertexStyle} = [shape = ellipse,minimum width= 6ex,draw]
\tikzstyle{EdgeStyle}   = [->,>=stealth']      
\begin{tikzpicture}[scale=0.5, auto=left,every node/.style={circle}]  
\SetGraphUnit{4} 
\Vertex[L=$x_{1}$]{x};
\Vertex[L=$h_{1}$]{h};
\EA(x){h}
\Edges(x)(h)
\end{tikzpicture}
\end{figure}
下面是我得到的结果:


对于您的代码,逐行执行以下操作:

\Vertex[L=$x_{1}$]{x};
这将创建一个名为
x
L
abel
$x_1$
的顶点(在原点)

\Vertex[L=$h_{1}$]{h};
\EA(x){h}
这也会创建一个名为
h
的顶点(在原点),该顶点带有
L
abel
$h\u 1$

\Vertex[L=$h_{1}$]{h};
\EA(x){h}
在这里,您向
x
EA
st添加一个顶点
h
。标签名是
h
,标签名也是

\Edges(x)(h)
现在您尝试在
x
h
之间添加一条边

\SetVertexMath
\Edges(h,h_2)

也许这是您可能感兴趣的事情:

\Vertex[x = 1cm, L = $x_1$]{x};
将一个名为
x
的顶点与
L
abel
$x_1$
1cm
位于原点以东,仅因如此)

L
abel
$h\u 1$
放置一个顶点
h
4cm
位于原点以东,这样它就不会位于/靠近
x

在节点
x
h
之间绘制一条边

\SetVertexMath
\Edges(h,h_2)
节点名称和标签将包括数学内容

\EA(h){h_2}
h
EA
st创建一个新顶点
h2

\SetVertexMath
\Edges(h,h_2)
h
h_2
之间绘制另一条边

下面是一个完整的最小示例: