2

Using the answer here, I was able to draw a hexagonal grid. I would like to display only a circular region (centered at the origin) of this lattice, similarly to what was done in this question, but without the whole hexagon showing in the background. How would I do that?

Thanks!

\documentclass[11pt]{scrartcl}
\usepackage{fullpage}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{center}
\begin{tikzpicture}[x=1.5cm,y=1.5cm]
\newcommand*\rows{6}
\foreach \row in {0, ...,\rows}
    {
    \draw[blue!60]
        % hexagonal grid drawn in three steps corresponding to 3*2 opposite regions
        % diagonal
        ($\row*(0.5, {0.5*sqrt(3)})$) -- ($(\rows,0)+\row*(-0.5, {0.5*sqrt(3)})$)
        ($\row*(1, 0)$) -- ($(\rows/2,{\rows/2*sqrt(3)})+\row*(0.5,{-0.5*sqrt(3)})$)
        ($\row*(1, 0)$) -- ($(0,0)+\row*(0.5,{0.5*sqrt(3)})$)
        ($(0,0)-\row*(0.5, {0.5*sqrt(3)})$) -- ($(0,0)-(\rows,0)-\row*(-0.5,{0.5*sqrt(3)})$)
        ($(0,0)-\row*(1, 0)$) -- ($(0,0)-(\rows/2,{\rows/2*sqrt(3)})-\row*(0.5,{-0.5*sqrt(3)})$)
        ($(0,0)-\row*(1, 0)$) -- ($(0,0)-\row*(0.5,{0.5*sqrt(3)})$)
        % antidiagonal
        ($\row*(-0.5, {0.5*sqrt(3)})$) -- ($(-\rows,0)+\row*(+0.5, {0.5*sqrt(3)})$)
        ($\row*(-1, 0)$) -- ($(-\rows/2,{\rows/2*sqrt(3)})+\row*(-0.5,{-0.5*sqrt(3)})$)
        ($\row*(-1, 0)$) -- ($(0,0)+\row*(-0.5,{0.5*sqrt(3)})$)
        ($(0,0)-\row*(-0.5, {0.5*sqrt(3)})$) -- ($(0,0)-(-\rows,0)-\row*(+0.5, {0.5*sqrt(3)})$)
        ($(0,0)-\row*(-1, 0)$) -- ($(0,0)-(-\rows/2,{\rows/2*sqrt(3)})-\row*(-0.5,{-0.5*sqrt(3)})$)
        ($(0,0)-\row*(-1, 0)$) -- ($(0,0)-\row*(-0.5,{0.5*sqrt(3)})$)
        % vertical strip
        ($\row*(-0.5, {0.5*sqrt(3)})$) -- ($\row*(0.5, {0.5*sqrt(3)})$)
        ($\rows*(-0.5, {0.5*sqrt(3)})+\row*(1,0)$) -- ($\row*(0.5, {0.5*sqrt(3)})$)
        ($\row*(-0.5, {0.5*sqrt(3)})$) -- ($\rows*(0.5, {0.5*sqrt(3)})+\row*(-1,0)$)
        ($(0,0)-\row*(-0.5, {0.5*sqrt(3)})$) -- ($(0,0)-\row*(0.5, {0.5*sqrt(3)})$)
        ($(0,0)-\rows*(-0.5, {0.5*sqrt(3)})-\row*(1,0)$) -- ($(0,0)-\row*(0.5, {0.5*sqrt(3)})$)
        ($(0,0)-\row*(-0.5, {0.5*sqrt(3)})$) -- ($(0,0)-\rows*(0.5, {0.5*sqrt(3)})-\row*(-1,0)$);
    }
\end{tikzpicture}
\end{center}
\end{document}
  • A possibility would be to save the exagon in a standalone pdf and then include the part you are interested with includegraphics with the appropriate scale,crop etc. options. But I'm not sure this is what you want. – d-cmst Oct 07 '14 at 17:27

1 Answers1

3

You can add a \clip before the drawing. Below i added \clip (0,0) circle (4.75cm); so that we only see the grid within specified circle:

enter image description here

Code:

\documentclass[11pt]{scrartcl}
\usepackage{fullpage}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{center}
\begin{tikzpicture}[x=1.5cm,y=1.5cm]
\newcommand*\rows{6}
\clip  (0,0) circle (4.75cm);
\foreach \row in {0, ...,\rows} {
    \draw[blue!60, ultra thick]
        % hexagonal grid drawn in three steps corresponding to 3*2 opposite regions
        % diagonal
        ($\row*(0.5, {0.5*sqrt(3)})$) -- ($(\rows,0)+\row*(-0.5, {0.5*sqrt(3)})$)
        ($\row*(1, 0)$) -- ($(\rows/2,{\rows/2*sqrt(3)})+\row*(0.5,{-0.5*sqrt(3)})$)
        ($\row*(1, 0)$) -- ($(0,0)+\row*(0.5,{0.5*sqrt(3)})$)
        ($(0,0)-\row*(0.5, {0.5*sqrt(3)})$) -- ($(0,0)-(\rows,0)-\row*(-0.5,{0.5*sqrt(3)})$)
        ($(0,0)-\row*(1, 0)$) -- ($(0,0)-(\rows/2,{\rows/2*sqrt(3)})-\row*(0.5,{-0.5*sqrt(3)})$)
        ($(0,0)-\row*(1, 0)$) -- ($(0,0)-\row*(0.5,{0.5*sqrt(3)})$)
        % antidiagonal
        ($\row*(-0.5, {0.5*sqrt(3)})$) -- ($(-\rows,0)+\row*(+0.5, {0.5*sqrt(3)})$)
        ($\row*(-1, 0)$) -- ($(-\rows/2,{\rows/2*sqrt(3)})+\row*(-0.5,{-0.5*sqrt(3)})$)
        ($\row*(-1, 0)$) -- ($(0,0)+\row*(-0.5,{0.5*sqrt(3)})$)
        ($(0,0)-\row*(-0.5, {0.5*sqrt(3)})$) -- ($(0,0)-(-\rows,0)-\row*(+0.5, {0.5*sqrt(3)})$)
        ($(0,0)-\row*(-1, 0)$) -- ($(0,0)-(-\rows/2,{\rows/2*sqrt(3)})-\row*(-0.5,{-0.5*sqrt(3)})$)
        ($(0,0)-\row*(-1, 0)$) -- ($(0,0)-\row*(-0.5,{0.5*sqrt(3)})$)
        % vertical strip
        ($\row*(-0.5, {0.5*sqrt(3)})$) -- ($\row*(0.5, {0.5*sqrt(3)})$)
        ($\rows*(-0.5, {0.5*sqrt(3)})+\row*(1,0)$) -- ($\row*(0.5, {0.5*sqrt(3)})$)
        ($\row*(-0.5, {0.5*sqrt(3)})$) -- ($\rows*(0.5, {0.5*sqrt(3)})+\row*(-1,0)$)
        ($(0,0)-\row*(-0.5, {0.5*sqrt(3)})$) -- ($(0,0)-\row*(0.5, {0.5*sqrt(3)})$)
        ($(0,0)-\rows*(-0.5, {0.5*sqrt(3)})-\row*(1,0)$) -- ($(0,0)-\row*(0.5, {0.5*sqrt(3)})$)
        ($(0,0)-\row*(-0.5, {0.5*sqrt(3)})$) -- ($(0,0)-\rows*(0.5, {0.5*sqrt(3)})-\row*(-1,0)$);
    }
\end{tikzpicture}
\end{center}
\end{document}
Peter Grill
  • 223,288