如何使用 tikzpicture 环境在 latex 中绘制下图?

如何使用 tikzpicture 环境在 latex 中绘制下图?
\documentclass[a4paper, 12pt]{article}

\usepackage{graphicx}
\usepackage{amsfonts}
\usepackage{amsbsy}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{pst-all}
\usepackage{pstricks}
\usepackage{graphics}
\usepackage{epsfig}
\usepackage{pifont,geometry,txfonts,hyperref}
\begin{document}

\begin{figure}[ht]
\bpsp(3,3.7)
%\psgrid[subgriddiv=1,griddots=10,gridlabels=10pt](0,-1)(12,2)
\rput(2,1){
\psline(0,1)(1,2)(2,1)(1,0)
\psline(0,1)(1,0)

\psline(1,0)(1,2)
\psline(2,1)(2,2)(3,2)(2,1)(3,1)




%\psline(2,1)(2.5,0)(1.5,0)(2,1)


\psline(3,1)(4,2)(5,1)(4,0)(3,1)
\psline(5,1)(5,0)(6,0)(6,1)(5,1)
\psline(6,1)(7,1)(7,2)(6,2)(6,1)


%\psline(6,0)(6,-1)(7,-1)(7,0)(6,0)

\psline(6,1.5)(6.5,2)(7,1.5)(6.5,1)(6,1.5)

\psline(5,1)(5,2)
%\psline(5,2)(6,2)

%\psline(1.5,0)(2.3,.45)


\psline(8,1)(11,1)
\psdot(8,1)\psdot(8.75,1)\psdot(9.5,1)\psdot(10.25,1)\psdot(11,1)
\psdot(11.75,1)
%\psdot(11.5,.5)
%\psline(11,1)(11.5,.5)
\psline(11,1)(11.75,1)
\psline(8.75,.25)(8.75,1)
\psline(10.25,1)(10.25,1.75)
\psdot(5,1)\psdot(4,2)\psdot(4,0)
\psdot(10.25,1.75)
\psdot(8.75,.25)
\psdot(8.75,1.75)
\psline(8.75,1)(8.75,1.75)
\psline(8.75,.25)(8.75,-0.5)

\psdot(8.75,-0.5)
\rput(9,0.2){$u_2$}

\psdot(0,1)\psdot(1,2)\psdot(2,1)\psdot(1,0)
\psdot(2,1)\psdot(2,2)\psdot(3,2)\psdot(3,1)
\psdot(5,2)\psdot(5,1)
\psdot(6,1.5)\psdot(7,1.5)
\psdot(6.5,2)\psdot(6.5,1)

\psdot(6,1)\psdot(7,1)\psdot(7,2)\psdot(6,2)\psdot(5,0)\psdot(6,0)
%\psdot(7,0)
\psdot(2,-1)\psdot(3,-1)\psdot(3,0)
\psline(2,1)(2,0)\psdot(2,1)\psdot(2,0)
\psline(2,-1)(2,0)(3,0)(3,-1)(2,-1)
\rput(2.35,.8){$u_1$}
\rput(3.05,.75){$u_3$}
\rput(1.7,0){$u_2$}
\rput(5.2,.78){$u_4$}
\rput(6.2,.75){$u_5$}
\rput(8.95,.8){$u_1$}
\rput(9.5,.8){$u_3$}
\rput(10.25,.8){$u_4$}
\rput(11,.8){$u_5$}

}
\epsp
\caption{A restricted graph $G$ and its block structure $\B(G)$}
\end{figure}
\exa

\end{document}

我正在尝试用 LaTeX 画出这个图形。但没有成功。

答案1

正如通过所讨论的comment,如果删除标签\exa, \B(G), \epsp, \bpsp,那么我得到的输出为:

在此处输入图片描述

代码如下:

\documentclass[a4paper, 12pt]{article}

\usepackage{graphicx}
\usepackage{amsfonts}
\usepackage{amsbsy}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{pst-all}
\usepackage{pstricks}
\usepackage{graphics}
\usepackage{epsfig}
\usepackage{pifont,geometry,txfonts,hyperref}
\begin{document}

\begin{figure}[ht]
%\bpsp(3,3.7)
%\psgrid[subgriddiv=1,griddots=10,gridlabels=10pt](0,-1)(12,2)
\rput(2,1){
\psline(0,1)(1,2)(2,1)(1,0)
\psline(0,1)(1,0)

\psline(1,0)(1,2)
\psline(2,1)(2,2)(3,2)(2,1)(3,1)




%\psline(2,1)(2.5,0)(1.5,0)(2,1)


\psline(3,1)(4,2)(5,1)(4,0)(3,1)
\psline(5,1)(5,0)(6,0)(6,1)(5,1)
\psline(6,1)(7,1)(7,2)(6,2)(6,1)


%\psline(6,0)(6,-1)(7,-1)(7,0)(6,0)

\psline(6,1.5)(6.5,2)(7,1.5)(6.5,1)(6,1.5)

\psline(5,1)(5,2)
%\psline(5,2)(6,2)

%\psline(1.5,0)(2.3,.45)


\psline(8,1)(11,1)
\psdot(8,1)\psdot(8.75,1)\psdot(9.5,1)\psdot(10.25,1)\psdot(11,1)
\psdot(11.75,1)
%\psdot(11.5,.5)
%\psline(11,1)(11.5,.5)
\psline(11,1)(11.75,1)
\psline(8.75,.25)(8.75,1)
\psline(10.25,1)(10.25,1.75)
\psdot(5,1)\psdot(4,2)\psdot(4,0)
\psdot(10.25,1.75)
\psdot(8.75,.25)
\psdot(8.75,1.75)
\psline(8.75,1)(8.75,1.75)
\psline(8.75,.25)(8.75,-0.5)

\psdot(8.75,-0.5)
\rput(9,0.2){$u_2$}

\psdot(0,1)\psdot(1,2)\psdot(2,1)\psdot(1,0)
\psdot(2,1)\psdot(2,2)\psdot(3,2)\psdot(3,1)
\psdot(5,2)\psdot(5,1)
\psdot(6,1.5)\psdot(7,1.5)
\psdot(6.5,2)\psdot(6.5,1)

\psdot(6,1)\psdot(7,1)\psdot(7,2)\psdot(6,2)\psdot(5,0)\psdot(6,0)
%\psdot(7,0)
\psdot(2,-1)\psdot(3,-1)\psdot(3,0)
\psline(2,1)(2,0)\psdot(2,1)\psdot(2,0)
\psline(2,-1)(2,0)(3,0)(3,-1)(2,-1)
\rput(2.35,.8){$u_1$}
\rput(3.05,.75){$u_3$}
\rput(1.7,0){$u_2$}
\rput(5.2,.78){$u_4$}
\rput(6.2,.75){$u_5$}
\rput(8.95,.8){$u_1$}
\rput(9.5,.8){$u_3$}
\rput(10.25,.8){$u_4$}
\rput(11,.8){$u_5$}

}
%\epsp
\caption{A restricted graph $G$ and its block structure}
\end{figure}
%\exa

\end{document}

相关内容