I had been taking my Number theory class notes in latex and all is done except one last bit (which I have been postponing for ages now!).

I am trying to find the best way of transferring the following graph/chart into latex but was not sure which package should I choose.

enter image description here

I would really appreciate some guidance and suggestions.

P.S. I worked/have been working in Overleaf. Since the whole document is too long to be posted in this question, here is the link to it, in case it may be useful. (Let me know if it wouldn't work.)

P.S.S. I have previously worked with tikz mostly (for Graph Theory and Game Theory stuff) and some other packages which were mostly used to generate functional graphs; so, based on this experience, I was thinking this graph might be constructed with tikz as well.

  • 3
    It would be great if you could show us what you have tried. Posting a minimal working example that indicates what you are trying to do makes it easier for people to understand what you want. It also makes it easier for people to help you, since they have some code to start from, and hence much more likely that some one will try to help you. Please don't post your entire document. A MWE should be as small as possible to illustrate your problem.
    – user30471
    Commented Aug 31, 2020 at 2:08
  • @ElenKhachatryan please have a look at the solution with tkz-euclide given below if it meets your requirement
    – js bibra
    Commented Sep 1, 2020 at 1:31

4 Answers 4


In Tikz, you can use grid to draw the grid and then define a node that draws a filled small circle (in the code below plupp). After that it is mostly a matter of positioning text nodes.

\begin{tikzpicture}[plupp/.style={circle,draw,inner sep=1pt,fill=black}]
  \draw (0,0) grid (7,5);
  \node[anchor=north east] at (0,0){$0$};
  \node[anchor=south east] at (0,5){$\alpha$};
  \node[anchor=south west] at (7,5){$N$};
  \node[anchor=north west] at (7,0){$R$};
  \draw (0,0) -- (7,5);
  \node[plupp,label={180:$C$}] at (0,2){};
  \node[plupp,label={-90:$A$}] at (3,0){};
  \node[plupp,label=110:$P$] at (7*2/5,2){};
  \node[plupp,label=90:$\mu$] at (3,5*3/7){};
  \node[plupp,label=-45:$B$] at (3,2){};
  \draw[<->](0,-0.7) -- +(3,0) node[pos=0.5,fill=white]{$\tfrac{p-1}{2}$};
  \draw[<->](0,-1.3) -- +(7,0) node[pos=0.5,fill=white]{$p$};
  \draw[<->](-0.7,0) -- +(0,2) node[pos=0.5,fill=white]{$\tfrac{g-1}{2}$};
  \draw[<->](7.5,0) -- +(0,5) node[pos=0.5,fill=white]{$g$};

enter image description here

  • Thank you so much @StefanH ! Do you mind if I include you in my list of helpful contributors (so far it would be only you on the list (LOL) until a couple of people proofread everything), and if so, what name would you like me to use? (It is nothing official, and simply for my note-taking archive completion purposes. As of now, not intending to sell or profit from it :D.) Commented Sep 7, 2020 at 2:22
  • Just glad I could help. It is a very minor typographic contribution so you don't need to mention it.
    – StefanH
    Commented Sep 7, 2020 at 15:04

enter image description hereWell, here is a starter using the tikz package



\draw[gray, thick] (0,0) -- (0,6);
\draw[gray, thick] (1,0) -- (1,6);
\draw[gray, thick] (2,0) -- (2,6);
\draw[gray, thick] (3,0) -- (3,6);
\draw[gray, thick] (4,0) -- (4,6);
\draw[gray, thick] (5,0) -- (5,6);
\draw[gray, thick] (6,0) -- (6,6);
\draw[gray, thick] (7,0) -- (7,6);

\draw[gray, thick] (0,0) -- (7,0);
\draw[gray, thick] (0,1) -- (7,1);
\draw[gray, thick] (0,2) -- (7,2);
\draw[gray, thick] (0,3) -- (7,3);
\draw[gray, thick] (0,4) -- (7,4);
\draw[gray, thick] (0,5) -- (7,5);
\draw[gray, thick] (0,6) -- (7,6);
\draw[black, thick] (0,0) -- (7,6);

\filldraw[black] (0,0) circle (2pt) node[anchor=east] {0};
\filldraw[black] (0,2) circle (2pt) node[anchor=east] {C};
\filldraw[black] (7,0) circle (2pt) node[anchor=west] {R};
\filldraw[black] (0,6) circle (2pt) node[anchor=east] {2};
\filldraw[black] (7,6) circle (2pt) node[anchor=west] {N};



I am not sure about the intermediate points. If it were me I might have created it as a PowerPoint figure and export as pdf. To learn more about the tikz package, refer to this documentation:


I am pretty sure you can create the arrows and equation annotations using similar commands, as long as you know their desired positions on the page.

  • Would foreach shorten this answer quite a bit?
    – Simd
    Commented Aug 31, 2020 at 6:35
  • You should use grid instead of drawing the lines one by one, as in this answer.
    – Clément
    Commented Aug 31, 2020 at 12:27

Consider asymptote as an option.

enter image description here

// tab-numt.asy
// run 
//    asy tab-numt.asy
// to get a standalone pdf picture
//    tab-numt.pdf
pen linePen=darkblue+0.7bp, grayPen=gray(0.3)+0.7bp;
arrowbar arr=Arrows(HookHead,size=2);
int n=3, m=2, p=2*n+1, q=2*m+1;

guide hLine[], vLine[];
for(int i=0;i<=q;++i)hLine[i]=(0,i)--(p,i);
for(int i=0;i<=p;++i)vLine[i]=(i,0)--(i,q);

pair N=(p,q), O=(0,0), Q=(0,q), R=(p,0), 
  A=((p-1)/2,0), C=(0,(q-1)/2), B=(A.x,C.y),
pair[] pos={N,O,Q,R,A,B,C,P,M}; string name="NOQRABCPM";

draw(hLine,linePen); draw(vLine,linePen);

pair dx=(0.62,0), dy=(0,0.5);

draw((O-dy)--(A-dy),grayPen,arr); label("$\frac{p-1}2$",(O+A)/2-dy,UnFill);

draw((O-2dy)--(R-2dy),grayPen,arr); label("$p$",(O+R)/2-2dy,UnFill);

draw((O-dx)--(C-dx),grayPen,arr); label("$\frac{q-1}2$",(O+C)/2-dx,UnFill);

draw((N+dx)--(R+dx),grayPen,arr); label("$q$",(N+R)/2+dx,UnFill);


for(int i=0;i<7;++i) label("$"+substr(name,i,1)+"$",pos[i],unit(pos[i]-Z));
label("$M$",M,plain.NW); label("$P$",P,plain.S);

a tkz-euclide solution

enter image description here


 % \usepackage{amsmath}

                %the grid
                %the axes
%               \tkzDrawX[label={}]
%               \tkzDrawY[label={}]
                %draw the points O, R, 2, N, A, C
                %segment ON
                %calculate intersections for point P, M, B
%               \tkzDrawLine(C,Xc)%
%               \tkzDrawLine(A,Xa)
                \tkzLabelPoints[above left,font=\tiny](P)
                \tkzLabelPoints[above,font=\tiny, xshift=-4pt](M)
                %some labels

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .