我很惊讶我还没能在这里找到这个答案;我想用数学模式标记一个顶点,没有等号,并且澄清一下,这不是一个节点,而是一个顶点,也许重写 tikzpic 可能会有效,但我更想知道如何用这种方式解决它。
无论如何,我不想混淆,我想用花括号下的标签标记我的顶点;我用其中一个标签替换顶点以说明它不起作用。第一个例子有效,我用 {$\frac{\gamma+1}{\gamma+\delta+1}$} 替换节点 c。第二个是我想要的,但没有(作为参考,看我的图片,我用 {$\frac{\gamma+1}{gamma+delta+1}$} 或它的一些变体替换顶点标签 c)。
\newlength{\bulletwidth}\settowidth{\bulletwidth}{$\bullet$}
\newcommand{\mitem}{\setlength{\leftskip}{\leftmargin}\hspace*{-\labelsep}\hspace*{-\bulletwidth}$\bullet$\hspace*{\labelsep}}
\newcommand{\mend}{\setlength{\leftskip}{0cm}}
\documentclass[12pt]{article}
\usepackage{scrextend}%
%
\usepackage{graphicx,tikz,tkz-berge,tkz-graph}
\usetikzlibrary{trees,fit,shapes,arrows,calc, patterns,decorations.pathreplacing}%
\usepackage{lipsum,soul}%soul is forstrike-through\st{}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb,txfonts,soul,dsfont}
\usepackage{yfonts,mathrsfs}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=2.25]
\GraphInit[vstyle=Classic]
\SetUpVertex[Lpos=-90]
\tikzset{VertexStyle/.style = {shape=circle, fill=black, minimum size=3pt,inner sep=0pt}
}
\tikzset{
position label/.style={
below = 15pt,
text height = 1.5ex,
text depth = 2ex
},
brace/.style={
decoration={brace, mirror},
decorate
}
}
\Vertex[x=0,y=0]{d}
\Vertex[x=1.5,y=0]{c}
\Vertex[x=3,y=0]{b}
\Vertex[x=4.5,y=0]{a}
\Vertex[x=6,y=0]{p}
\tikzset{EdgeStyle/.style={-,font=\scriptsize,above,sloped,midway}}
\Edges[](d,c)
\Edges[](c,b)%
\Edges[](b,a)
\Edges[](a,p)
\draw [brace] (d.south) -- node [position label, pos=0.5] {$\frac{\gamma}{\gamma+\delta+1}$} (c.south);
\draw [brace] (c.south) -- node [position label, pos=0.5] {$\frac{\gamma}{\gamma+\delta}$} (b.south);
\draw [brace] (a.south) -- node [position label, pos=0.5] {$\frac{\gamma+1}{\gamma+\delta+1}$} (p.south);
\draw [brace] (b.south) -- node [position label, pos=0.5] {$(\frac{\gamma}{\gamma+\delta})(\frac{1+\beta \frac{\gamma+1}{(\gamma+1)+\delta}}{1+\beta \frac{\gamma}{\gamma+\delta}})$} (a.south);
\end{tikzpicture}%
\end{center}%
\end{document}
下面的一个是我想要工作的:
\newlength{\bulletwidth}\settowidth{\bulletwidth}{$\bullet$}
\newcommand{\mitem}{\setlength{\leftskip}{\leftmargin}\hspace*{-\labelsep}\hspace*{-\bulletwidth}$\bullet$\hspace*{\labelsep}}
\newcommand{\mend}{\setlength{\leftskip}{0cm}}
\documentclass[12pt]{article}
\usepackage{scrextend}%
%
\usepackage{graphicx,tikz,tkz-berge,tkz-graph}
\usetikzlibrary{trees,fit,shapes,arrows,calc, patterns,decorations.pathreplacing}%
\usepackage{lipsum,soul}%soul is forstrike-through\st{}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb,txfonts,soul,dsfont}
\usepackage{yfonts,mathrsfs}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=2.25]
\GraphInit[vstyle=Classic]
\SetUpVertex[Lpos=-90]
\tikzset{VertexStyle/.style = {shape=circle, fill=black, minimum size=3pt,inner sep=0pt}
}
\tikzset{
position label/.style={
below = 15pt,
text height = 1.5ex,
text depth = 2ex
},
brace/.style={
decoration={brace, mirror},
decorate
}
}
\Vertex[x=0,y=0]{d}
\Vertex[x=1.5,y=0]{{$\frac{\gamma}{\gamma+\delta+1}$}}
\Vertex[x=3,y=0]{b}
\Vertex[x=4.5,y=0]{a}
\Vertex[x=6,y=0]{p}
\tikzset{EdgeStyle/.style={-,font=\scriptsize,above,sloped,midway}}
\Edges[](d,c)
\Edges[]({$\frac{\gamma}{\gamma+\delta+1}$},b)%
\Edges[](b,a)
\Edges[](a,p)
\draw [brace] (d.south) -- node [position label, pos=0.5] {$\frac{\gamma}{\gamma+\delta+1}$} ({$\frac{\gamma}{\gamma+\delta+1}$}.south);
\draw [brace] ({$\frac{\gamma}{\gamma+\delta+1}$}.south) -- node [position label, pos=0.5] {$\frac{\gamma}{\gamma+\delta}$} (b.south);
\draw [brace] (a.south) -- node [position label, pos=0.5] {$\frac{\gamma+1}{\gamma+\delta+1}$} (p.south);
\draw [brace] (b.south) -- node [position label, pos=0.5] {$(\frac{\gamma}{\gamma+\delta})(\frac{1+\beta \frac{\gamma+1}{(\gamma+1)+\delta}}{1+\beta \frac{\gamma}{\gamma+\delta}})$} (a.south);
\end{tikzpicture}%
\end{center}%
\end{document}
答案1
好的,我在这里发布一些可能朝着正确方向发展的内容。之所以花了这么长时间,是因为我不得不放弃很多这里不需要的包。问题是你不能将这些数学表达式用作节点名称,例如\path (0,0) node ($\frac{1}{2}$) {$\frac{1}{2}$};
将失败。当然,你可以将它们用作节点内容. 这是以下MWE的基础。
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{tikz,tkz-berge,tkz-graph}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=2.25]
\GraphInit[vstyle=Classic]
\SetUpVertex[Lpos=-90]
\tikzset{VertexStyle/.style = {shape=circle, fill=black, minimum size=3pt,inner sep=0pt}}
\tikzset{
position label/.style={
below = 15pt,
text height = 1.5ex,
text depth = 2ex
},
brace/.style={
decoration={brace, mirror},
decorate
}
}
\node[VertexStyle] (d) at (0,0){};
\node (c) at (1.5,0) {$\frac{\gamma}{\gamma+\delta+1}$};
\node[VertexStyle] (b) at (3,0){};
\node[VertexStyle] (a) at (4.5,0){};
\node[VertexStyle] (p) at (6,0){};
\tikzset{EdgeStyle/.style={-,font=\scriptsize,above,sloped,midway}}
\Edges[](d,c)
\Edges[](c,b)%
\Edges[](b,a)
\Edges[](a,p)
\draw [brace] (d |- c.south) -- node [position label, pos=0.5] {$\frac{\gamma}{\gamma+\delta+1}$} (c.south);
\draw [brace] (c.south) -- node [position label, pos=0.5] {$\frac{\gamma}{\gamma+\delta}$} (b|- c.south);
\draw [brace] (a|- c.south) -- node [position label, pos=0.5] {$\frac{\gamma+1}{\gamma+\delta+1}$} (p|- c.south);
\draw [brace] (b|- c.south) -- node [position label, pos=0.5] {$(\frac{\gamma}{\gamma+\delta})(\frac{1+\beta \frac{\gamma+1}{(\gamma+1)+\delta}}{1+\beta \frac{\gamma}{\gamma+\delta}})$} (a|- c.south);
\end{tikzpicture}%
\end{center}%
\end{document}