如何使用 tkz-graph 创建包含数学内容的顶点?

如何使用 tkz-graph 创建包含数学内容的顶点?

好的,我的目标是用 LaTeX 制作这样的图表:

在此处输入图片描述

不同之处在于,我希望您看到dotsdots2显示$\ldots$。我正在尝试使用 tkz-graph 包来实现这一点。我对 tikz 的唯一经验就是该包,因此我尝试以这种方式执行此操作。我知道我可以使用来\Vertices{line}{0,1,dots,i,i+1,dots2}获取一条线上的所有顶点,但我不知道如何获取带有数学运算的顶点。我试过了,\Vertices{line}{0,1,$\ldots$,i,i+1,dots2}但那行不通。

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amssymb, amsthm}
\usepackage{tkz-graph}
\tikzset{EdgeStyle/.append style = {->}}
\tikzset{LabelStyle/.style= {draw,
fill = white,
text = black}}

\begin{document}
\begin{tikzpicture}
\SetGraphUnit{2}
\Vertices{line}{0,1,dots,i,i+1,dots2}
\Edge[label=q](1)(0)
\tikzset{EdgeStyle/.append style = {bend left}}
\Edge[label=p](1)(dots)
\Edge[label=q](dots)(1)
\Edge[label=p](dots)(i)
\Edge[label=q](i)(dots)
\Edge[label=p](i)(i+1)
\Edge[label=q](i+1)(i)
\Edge[label=p](i+1)(dots2)
\Edge[label=q](dots2)(i+1)
\end{tikzpicture}
\end{document}

答案1

您可以使用Math选项。但这不能与其他没有数学内容的顶点混合。因此我们必须分割整条线并使用xy值来正确定位它们:

\Vertices{line}{0,1}
\Vertex[Math,L=\ldots,x=4,y=0] {dots}
\Vertices[x=6,y=0]{line}{i,i+1}
\Vertex[Math,L=\ldots,x=10,y=0] {dots2}

完整代码:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amssymb, amsthm}
\usepackage{tkz-graph}
\tikzset{EdgeStyle/.append style = {->}}
\tikzset{LabelStyle/.style= {draw,
fill = white,
text = black}}

\begin{document}
\begin{tikzpicture}
\SetGraphUnit{2}
\Vertices{line}{0,1}
\Vertex[Math,L=\ldots,x=4,y=0] {dots}
\Vertices[x=6,y=0]{line}{i,i+1}
\Vertex[Math,L=\ldots,x=10,y=0] {dots2}
\Edge[label=q](1)(0)
\tikzset{EdgeStyle/.append style = {bend left}}
\Edge[label=p](1)(dots)
\Edge[label=q](dots)(1)
\Edge[label=p](dots)(i)
\Edge[label=q](i)(dots)
\Edge[label=p](i)(i+1)
\Edge[label=q](i+1)(i)
\Edge[label=p](i+1)(dots2)
\Edge[label=q](dots2)(i+1)
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容