这是我使用的代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\newcommand{\LD}{\langle}
\newcommand{\RD}{\rangle}
\begin{document}
\begin{tikzpicture} [scale=0.4]
\tikzstyle{every node}=[draw,circle,fill=white,minimum size=1pt,
inner sep=0pt]
\draw node (1) [label=$v_{1,1}$] {}
-- ++(330:2.0cm) node (2) [] {}
-- ++(270:2.0cm) node (3)
[label=left:$v_{n,1}$] {}-- ++(300:2.0cm) node (4)
[] {}-- ++(210:2.0cm) node (5)
[] {}-- ++(120:2.0cm) node (6)
[] {}-- ++(150:2.0cm) node (7)
[] {}
-- ++(90:2.0cm) node (8)
[] {}
-- ++(30:2.0cm) node (1)
{};
\path [](1) edge (2);
\path [](2) edge (3);
\path [dashed](3) edge (4);
\path [dashed](5) edge (6);
\path [](6) edge (7);
\path [](7) edge (8);
\path [](8) edge (1);
\draw {}
-- ++(0:6.0cm) node (1') []
{}
-- ++(330:2.0cm) node (2) [] {}
-- ++(270:2.0cm) node (3)
[] {}-- ++(300:2.0cm) node (4)
[] {}-- ++(210:2.0cm) node (5)
[] {}-- ++(120:2.0cm) node (6)
[] {}-- ++(150:2.0cm) node (7)
[] {}
-- ++(90:2.0cm) node (8)
[] {}
-- ++(30:2.0cm) node (1)
{};
\path [](1) edge (2);
\path [](2) edge (3);
\path [dashed](3) edge (4);
\path [dashed](5) edge (6);
\path [](6) edge (7);
\path [](7) edge (8);
\path [](8) edge (1);
\draw {}
-- ++(0:12.0cm) node (1') []
{}
-- ++(330:2.0cm) node (2) [] {}
-- ++(270:2.0cm) node (3)
[] {}-- ++(300:2.0cm) node (4)
[] {}-- ++(210:2.0cm) node (5)
[] {}-- ++(120:2.0cm) node (6)
[] {}-- ++(150:2.0cm) node (7)
[] {}
-- ++(90:2.0cm) node (8)
[] {}
-- ++(30:2.0cm) node (1)
{};
\path [](1) edge (2);
\path [](2) edge (3);
\path [dashed](3) edge (4);
\path [dashed](5) edge (6);
\path [](6) edge (7);
\path [](7) edge (8);
\path [](8) edge (1);
\end{tikzpicture}
\end{document}
答案1
只需添加
\draw (4) node[below,xshift=-4mm,draw=white]{Layer *};
位于两个多边形下方。这给出:
我习惯xshift=-4mm
将标签稍微移动一点(即4mm
向左移动)。您可能需要对此进行微调。同样,如果您想将标签向下移动,例如,2mm
则将其替换below
为below=2mm
。
完整代码如下:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\newcommand{\LD}{\langle}
\newcommand{\RD}{\rangle}
\begin{document}
\begin{tikzpicture} [scale=0.4]
\tikzstyle{every node}=[draw,circle,fill=white,minimum size=1pt,
inner sep=0pt]
\draw node (1) [label=$v_{1,1}$] {}
-- ++(330:2.0cm) node (2) [] {}
-- ++(270:2.0cm) node (3)
[label=left:$v_{n,1}$] {}-- ++(300:2.0cm) node (4)
[] {}-- ++(210:2.0cm) node (5)
[] {}-- ++(120:2.0cm) node (6)
[] {}-- ++(150:2.0cm) node (7)
[] {}
-- ++(90:2.0cm) node (8)
[] {}
-- ++(30:2.0cm) node (1)
{};
\path [](1) edge (2);
\path [](2) edge (3);
\path [dashed](3) edge (4);
\path [dashed](5) edge (6);
\path [](6) edge (7);
\path [](7) edge (8);
\path [](8) edge (1);
\draw (4) node[below,xshift=-4mm,draw=white]{Layer 1};
\draw {}
-- ++(0:6.0cm) node (1') []
{}
-- ++(330:2.0cm) node (2) [] {}
-- ++(270:2.0cm) node (3)
[] {}-- ++(300:2.0cm) node (4)
[] {}-- ++(210:2.0cm) node (5)
[] {}-- ++(120:2.0cm) node (6)
[] {}-- ++(150:2.0cm) node (7)
[] {}
-- ++(90:2.0cm) node (8)
[] {}
-- ++(30:2.0cm) node (1)
{};
\path [](1) edge (2);
\path [](2) edge (3);
\path [dashed](3) edge (4);
\path [dashed](5) edge (6);
\path [](6) edge (7);
\path [](7) edge (8);
\path [](8) edge (1);
\draw (4) node[below,xshift=-4mm,draw=white]{Layer 2};
\draw {}
-- ++(0:12.0cm) node (1') []
{}
-- ++(330:2.0cm) node (2) [] {}
-- ++(270:2.0cm) node (3)
[] {}-- ++(300:2.0cm) node (4)
[] {}-- ++(210:2.0cm) node (5)
[] {}-- ++(120:2.0cm) node (6)
[] {}-- ++(150:2.0cm) node (7)
[] {}
-- ++(90:2.0cm) node (8)
[] {}
-- ++(30:2.0cm) node (1)
{};
\path [](1) edge (2);
\path [](2) edge (3);
\path [dashed](3) edge (4);
\path [dashed](5) edge (6);
\path [](6) edge (7);
\path [](7) edge (8);
\path [](8) edge (1);
\end{tikzpicture}
\end{document}
答案2
只是想发布代码的简短版本。评论中的内容不太清楚。这可以为您节省大量输入时间。
结果
平均能量损失
\documentclass[convert]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\newcommand{\radius}{0.75 cm} %Radius of the hexagons
\begin{document}
\begin{tikzpicture}
\foreach \x in {1, 2, 3}{
\begin{scope}[xshift=\x*1.75 cm]
% Draw hexagons
\draw (-30:\radius)
\foreach [count=\i] \a in {-30, 30,90,...,270} { %\a is the angle variable
--(\a:\radius) node[fill, circle, inner sep=1pt] (\i) {}
};
% Dotted lines
\draw[dashed] (1)--++(-60:\radius);
\draw[dashed] (6)--++(-60:\radius);
% Layer number
\ifnum \x<3
\node [below=of 6, yshift=5] {Layer \x};
\fi
% Node number
\ifnum \x=1
\node[left] at (1) {$v_{n, 1}$};
\node[above] at (3) {$v_{1, 1}$};
\fi
\end{scope}
}
\end{tikzpicture}
\end{document}