3

I am wondering how to generate a specific image with TikZ. This image is essentially a lattice grid without the grid, with a triangle, rectangle, and other shapes overlayed in a particular way. I would also like to be able to notate points on specific lattice points. Here is an example of what I would like to create:

Names of points substitute for lattice points

Thank you so much!

3
  • 2
    Welcome to SE. Just showing an image and asking people to do your work for you is frowned upon here. Show your attempt, and people will help make it better or correct it. Thank you.
    – Miyase
    Jun 26, 2022 at 21:43
  • @Miyase I didn't know, so I'm sorry. I'm rather new to TikZ, so I have no idea where to even begin when it comes to generating a graphic like this. Do you have any suggestions? Thanks
    – Tricryo
    Jun 26, 2022 at 21:45
  • Simply have a look at the TikZ page on CTAN. You'll find a minimal guide, and the main manual starts with a tutorial that should be enough to make the image you want.
    – Miyase
    Jun 26, 2022 at 21:49

2 Answers 2

5

The dotted grid can be made with with the \draw command with grid but use line cap=round, dash pattern=on 0pt off 1cm (assuming you want 1cm grid spacing). Then the triangle can be made with a \draw command and labeled at the vertices using node.

enter image description here

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw[line width=2pt, line cap=round, dash pattern=on 0pt off 1cm](0,0) grid (9,6);
\draw (0,0)node[below]{$(0,0)$}--(8.5,0)node[below]{$(\frac{p}{2},0)$}--(8.5,5.5)node[above]{$(\frac{p}{2},\frac{q}{2})$}--cycle;
\end{tikzpicture}

\end{document}
3
  • +1 It is a nice trick to draw a dot pattern. One weird thing is that you can not always trust it because of rounding error(?) in the grid - try ...(0,0) grid (1,1); (a dot will be missing). See also tex.stackexchange.com/questions/572993/… Jun 26, 2022 at 23:37
  • 1
    @hpekristiansen: Yes. The rounding issue can be resolved with (0,0) grid (1.1,1.1). You can also resolve the linked issue this way, e.g., (0,0) grid (1.00001,1.00001).
    – Sandy G
    Jun 26, 2022 at 23:54
  • 1
    Not important, but just a remark that might be useful in other situations: With ...grid[xstep=-1]... only horizontal grid lines will be draw and in this situation the dots will only be drawn once. Jun 27, 2022 at 2:03
4

As @Miyase said, you can found all what you need to draw a TiKz picture on CTAN. This answer is only for a starting point for you.

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, calc}
\tikzset{circle node/.style = {circle,inner sep=1pt,draw, fill=white}        
}

\begin{document}
  \begin{tikzpicture}[scale=0.5]
    \foreach \x in {0,...,9}
    \foreach \y in {0,...,6}
    {
    \fill (\x,\y) circle (1pt);
    }
    \foreach \y in {0,...,6}
    {
    \fill (10,\y) circle (1pt);
    }
    \foreach \x in {0,...,8}
    {
    \fill (\x,7) circle (1pt);
    }
    \draw (0,0)--(9.5,0)--(9.5,6.5)--cycle;
    \node at (0,0)[below]{$(0,0)$};
    \node at (9.5,0)[below]{$(\frac{p}{2},0)$};
    \node at (9.5,6.5)[above]{$(\frac{p}{2},\frac{q}{2})$};
  \end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.