1

Does tikz provide a way to draw text at a particular coordinate location? I am trying to fill the contents of a grid with fractions.

0

1 Answer 1

3

You can use a matrix of math nodes. One has to account for the line width at some places.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
 \node[matrix of math nodes,anchor=south west,inner sep=0pt,
    xshift=-\pgflinewidth,yshift=-\pgflinewidth,
    nodes={draw,minimum size=1cm,anchor=center},
    column sep=-\pgflinewidth,row sep=-\pgflinewidth]
    {\frac{1}{2} & \frac{1}{3} \\
    \frac{1}{4} & \frac{1}{5}\\};
 \draw[red,dashed] (0,0) grid (2,2);    
\end{tikzpicture}
\end{document}

enter image description here

The dashed grid is just to illustrate that the node boundaries really line up with a grid.

You must log in to answer this question.

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