1

I'm making a grid using tikz, and I need to write some variables on the side in the middle of the lines. This is the result I would like to get

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage[T1]{fontenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{amsmath}
\usepackage[normalem]{ulem}
\usepackage{bm}
\usepackage[absolute,overlay]{textpos}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=black}
\usepackage{tikz}
\usepackage{ragged2e}
\usepackage{graphicx}
\usepackage[label=corner]{karnaugh-map}
\usepackage[dvipsnames]{xcolor}
\usepackage{comment}
\usetikzlibrary{arrows,shapes.gates.logic.US,shapes.gates.logic.IEC,calc}
\tikzstyle{branch}=[fill,shape=circle,minimum size=3pt,inner sep=0pt]

\begin{document}

    \begin{textblock*}{200pt}(150pt,150pt)
        \begin{tikzpicture}[scale=0.5]
            \draw[step=1cm,black, thick] (0.1, 0.1) grid (8.9,6.9);
            \fill[red] (1,6) circle (0.2cm);
            \def\ynode{0, 1, 2, 3, 4, 5}
            \def\names{F , E , D , C , B , A}
            \begin{scope}<+->;
                %\foreach \y/\ytext in { 6/A, 5/B, 4/C, 3/D, 2/E, 1/F}
                %\foreach \n/\ytext in {\ynode/\names}{
                    %\draw[black, midway, xshift=-12pt, yshift=\y cm]  node[below] {$\ytext$};
                    %[xshift=-4pt,yshift=0pt]
                    %(0,0) -- (0,2) node [black,midway,xshift=-0.6cm] 
                    %{\footnotesize F};%}
            \end{scope}
        \end{tikzpicture}
    \end{textblock*}
    
\end{document}

I did some tries and I got the number part right but I can't understand how to write the letters.

1 Answer 1

2

Since you're labeling every horizontal and vertical line, you don't really gain anything by using grid. Two \foreach loops draws and labels each line.

Note the use of \tikzset, which should be used instead of the out-of-date \tikzstyle.

enter image description here

\documentclass{article}

\usepackage{tikz}
\tikzset{branch/.style={fill, circle, minimum size=5pt, inner sep=0pt}}

\begin{document}

\begin{tikzpicture}[scale=.5]
\foreach \y[count=\n] in {F,...,A} \draw[thick] (.1,\n)node[left]{\y}--(7.9,\n);
\foreach \x[count=\n] in {0,2,5,6,9,11,12} \draw[thick] (\n,.1)node[below]{\x}--(\n,6.9);
\foreach \x/\y in {1/6,2/6,2/5,4/5,3/4,5/4,4/3,6/3,5/2,7/2,6/1,7/1} \node[branch] at (\x,\y){};
\end{tikzpicture}

\end{document}

You must log in to answer this question.

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