绘制六角形格子,其路径用深黑色标记,中间边缘

绘制六角形格子,其路径用深黑色标记,中间边缘

我在乳胶中绘制以下图表时遇到困难:- 在此处输入图片描述

我需要按照相同的方向但选择加粗边缘和中点来绘制它。

答案1

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\makeatletter
\newcommand\hexsize{8pt} % length of the side of the hexagons
\begin{document}
\begin{tikzpicture}[
  x=\hexsize,
  y=\hexsize,
  square/.style={draw,fill,minimum size=1.5pt,inner sep=0pt},
  dot/.style={circle,circle,fill,minimum size=2pt,inner sep=0pt}
  ]
  % draw hexagonal grid
  \foreach \x in {0,...,12} {
    \coordinate(X) at (0:1.5*\x);
    \ifodd\x
      \def\ymax{9}
      \coordinate(X) at ($(X)+(0:0.5)+(-120:1)$);
    \else
      \def\ymax{8}
    \fi
    \foreach \y in {0,...,\ymax} {
      \coordinate (\x-\y) at ($(X)+(60:\y)+(120:\y)$);
      \draw[gray] (\x-\y) +(-60:1)
      \foreach \z [remember=\z as \lastz (initially 5)] in {0,...,5} {
        -- coordinate(\x-\y-\lastz-m) +(\z*60:1) coordinate(\x-\y-\z)
      } -- cycle;
    } 
  }
  % show coordinates of hexagons
  % \foreach \x in {0,...,12} {
  %   \ifodd\x
  %     \def\ymax{9}
  %   \else
  %     \def\ymax{8}
  %   \fi
  %   \foreach \y in {0,...,\ymax} {
  %     \node at (\x-\y) {\tiny\x-\y};
  %   }
  %   }
  % draw bold dotted hexagons
  \foreach \dt in {%
    2-5,3-5,3-6,4-6,4-7%
  } {\foreach \z in {0,...,5} {\node[dot] at (\dt-\z) {};}}
  % draw filled squares
  \foreach \sq in {
    1-1-5,1-1-1,1-2-1,1-3-1,1-4-1,1-5-1%
  } {\node[square] at (\sq-m) {};}
  % draw bold path
  \draw[thick]
  (5-5-5-m) node[square,label={[xshift=-3pt]right:$z$}]{}
  -- (5-4-1) -- (5-4-0) -- (5-4-5)
  -- (5-4-4) -- (5-4-3) -- (4-3-2) -- (4-3-3)
  -- (4-3-3-m) node[square,label={[xshift=-3pt]right:$a$}]{};
  % legend
  \node at (4-6) {$\Omega$};
  \node[square,label={[xshift=-4pt,yshift=4pt]right:\small mid-edge}] at (12-1-1-m){};
  \node[dot,label={[xshift=-4pt,yshift=4pt]right:\small vertex}] at (12-0-2){};
\end{tikzpicture}
\end{document}

六边形的中心标记如下:

在此处输入图片描述

六边形的角x按逆时针方向(从 3 点钟开始)标记为x-0x-1、 ... 、x-5。每条边的中点通过附加 获得。例如,和-m之间的中点标记为。3-5-33-5-43-5-3-m

相关内容