![下图中有三个多边形。我需要将第一个多边形下方标记为“第 1 层”,将第二个多边形下方标记为“第 2 层”](https://linux22.com/image/340398/%E4%B8%8B%E5%9B%BE%E4%B8%AD%E6%9C%89%E4%B8%89%E4%B8%AA%E5%A4%9A%E8%BE%B9%E5%BD%A2%E3%80%82%E6%88%91%E9%9C%80%E8%A6%81%E5%B0%86%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%A4%9A%E8%BE%B9%E5%BD%A2%E4%B8%8B%E6%96%B9%E6%A0%87%E8%AE%B0%E4%B8%BA%E2%80%9C%E7%AC%AC%201%20%E5%B1%82%E2%80%9D%EF%BC%8C%E5%B0%86%E7%AC%AC%E4%BA%8C%E4%B8%AA%E5%A4%9A%E8%BE%B9%E5%BD%A2%E4%B8%8B%E6%96%B9%E6%A0%87%E8%AE%B0%E4%B8%BA%E2%80%9C%E7%AC%AC%202%20%E5%B1%82%E2%80%9D.png)
这是我使用的代码:
\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}