tikz 中的边缘/顶点标签 - 书籍或独立文档类中的不同行为

tikz 中的边缘/顶点标签 - 书籍或独立文档类中的不同行为

当然,我是 tikz 新手;我现在的问题是创建一个简单的图形,如果我使用独立文档类,它的边缘标签会表现正确,但在书籍类中,边缘标签都出现在同一个位置,与所需的位置不符。我尝试过在 \path 或 \draw 中更改边缘参数,但没有成功。有人有建议或知道如何在书籍类中修复这个问题吗?

我的文本文档是:

\documentclass[12pt,a4paper,oneside]{book}
\usepackage{amsmath}    
\usepackage{amsthm}
\usepackage{epsfig}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[colorlinks=true,linkcolor=red,urlcolor=blue,citecolor=magenta]{hyperref}
\usepackage{algorithm}
\usepackage{algpseudocode} 
\usepackage{tikz}
 \usetikzlibrary{calc,shapes.geometric,arrows,positioning,intersections,quotes}
\usepackage{endnotes}
\usepackage[position=bottom]{subfig} %for subfloat

\begin{document}

\begin{tikzpicture}[]
\newcommand{\vertex}{\node[vertex]} %For tikz picture
\tikzstyle{vertex}=[circle, draw, inner sep=0pt, minimum size=6pt]

%极坐标 \vertex (w) 位于 (18:1) {}; \vertex (w1) 位于 (3:1.5) {}; \vertex (w2) 位于 (33:1.5) {};

\vertex (u) at (90:1) {};
\vertex (u1) at (75:1.5) {};
\vertex (u2) at (105:1.5) {};

\vertex (v) at (162:1) {};
\vertex (v1) at (147:1.5) {};
\vertex (v2) at (177:1.5) {};

\vertex (x) at (234:1) {};
\vertex (x1) at (219:1.5) {};
\vertex (x2) at (249:1.5) {};

%\draw[gray, fill=gray]  (0.76,-1.1) circle (0.7);
\begin{scope}[]
\vertex[label=left:{$x$}] (y)  at (306:1) {};
\vertex (y1) at (291:1.5) {};
\vertex (y2) at (321:1.5) {};
\end{scope}
    \begin{scope}
    \draw (v) edge (u);
    \end{scope}
    \path 
    (u) edge (w)
    (v) edge (x)
    (x) edge [above, "$U$"] (y)
    (w1) edge (w2)
    (w) edge (w1)
    (w) edge (w2)
    (u) edge (u1)
    (u) edge (u2)
    (u1) edge (u2)
    (v) edge (v1)
    (v) edge (v2)
    (v1) edge (v2)
    (x) edge (x1)
    (x) edge (x2)
    (x1) edge (x2)
    (y) edge (y1) 
    (y) edge (y2)
    (y1) edge (y2)
;
\draw[loosely dotted,thick] (w)--(y);

\end{tikzpicture}

\end{document}

显示输出: 在此处输入图片描述

使用独立的文件是:

\documentclass[border=10pt]{standalone}
\usepackage{tikz,tkz-graph,tkz-berge} 
\usetikzlibrary{arrows.meta, positioning, quotes}
\usetikzlibrary{arrows, quotes}

\begin{document}

\begin{tikzpicture}[]
\newcommand{\vertex}{\node[vertex]} %For tikz picture
\tikzstyle{vertex}=[circle, draw, inner sep=0pt, minimum size=6pt]
%polar coordinates
\vertex (w) at (18:1) {};
\vertex (w1) at (3:1.5) {};
\vertex (w2) at (33:1.5) {};

\vertex (u) at (90:1) {};
\vertex (u1) at (75:1.5) {};
\vertex (u2) at (105:1.5) {};

\vertex (v) at (162:1) {};
\vertex (v1) at (147:1.5) {};
\vertex (v2) at (177:1.5) {};

\vertex (x) at (234:1) {};
\vertex (x1) at (219:1.5) {};
\vertex (x2) at (249:1.5) {};

%\draw[grey, fill=gray]  (0.76,-1.1) circle (0.7);
\vertex (y) at (306:1) {};
\vertex (y1) at (291:1.5) {};
\vertex (y2) at (321:1.5) {};

    \draw (v) edge ["x"] (u);
    \path 
    (u) edge (w)
    (v) edge (x)
    (x) edge ["$U$"] (y)
    (w1) edge (w2)
    (w) edge (w1)
    (w) edge (w2)
    (u) edge (u1)
    (u) edge (u2)
    (u1) edge (u2)
    (v) edge (v1)
    (v) edge (v2)
    (v1) edge (v2)
    (x) edge (x1)
    (x) edge (x2)
    (x1) edge (x2)
    (y) edge (y1) 
    (y) edge (y2)
    (y1) edge (y2)
;
\draw[loosely dotted,thick] (w)--(y);
    %\foreach \i in {0.25,0.5,0.75}
    %\fill ($(w)!\i!(y)$) circle[radius=1pt]
\end{tikzpicture}

\end{document}

它显示:

在此处输入图片描述

提前致谢...

相关内容