0
\documentclass[tikz,border95=3mm]{article}

\usepackage{tikz}
\usepackage{xcolor}

\begin{document}


\begin{tikzpicture}[case/.style={minimum width=2cm,minimum height=2cm,draw},line/.style={blue!10!gray,line width=4,line cap=round,line join=round}]
\node[case] (a) at (0,0){} ;
\node[case] (b) at (2,0){} ;
\node[case] (c) at (0,2){} ;
\node[case] (d) at (2,2){} ;

\draw[line] (c.south west) -- (c.north west) -- (c.north east) -- (c.south west)-- ++(-1,-1);
\draw[line] (c.south west) -- (c.south east) -- (c.north east) -- (d.north east)-- (a.south west) -- ++(-1,-1);
\draw[line] (d.north east) -- (b.north east) -- (b.north west) -- (b.south west)-- (a.south west) -- (a.north  west);
\draw[line] (b.south west) -- (b.south east) -- (b.north east) -- (b.south west)-- ++(-1.25,-1.25);

\node[left=0.5 cm,above] at (a) {\huge 2};
\node[above=0.25 cm] at (c.north) {\huge 4};
\node[above=0.25 cm] at (d.north) {\huge 5};
\node[text=green,shift={(0.5,0.5)}] at (d.north east) { \huge $\times$};

\end{tikzpicture}


\end{document}

I am not used to using nodes and positioning in TikZ I have read latex draw tutorial but can't manage to make it a 3 by 1 grid, Any help?

3
  • What's a "3 by 1 grid"? How is it related with your code?
    – Ignasi
    Jun 3 at 13:39
  • Can you clarify the question? A picture of the intended output would be helpful.
    – Vincent
    Jun 3 at 13:39
  • 3 squares across and one layer but keeping the diagonal line extending the bottom left corners
    – Paul A
    Jun 3 at 13:40

2 Answers 2

0

Something like this?

\documentclass[tikz,border95=3mm]{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[case/.style={minimum width=2cm,minimum height=2cm,draw},line/.style={blue!10!gray,line width=4,line cap=round,line join=round}]
\node[case] (a) at (0,0){} ;
\node[case] (b) at (2,0){} ;
\node[case] (c) at (4,0){} ;
%\node[case] (d) at (2,2){} ;

\draw[line] (a.south west) -- (a.north west) -- (a.north east) -- (a.south west)-- ++(-1,-1);
\draw[line] (b.south west) -- (b.north west) -- (b.north east) -- (b.south west)-- ++(-1,-1);
\draw[line] (c.south west) -- (c.north west) -- (c.north east) -- (c.south west)-- ++(-1,-1);
\draw[line] (a.south west) -- (c.south east) -- (c.north east);

\node[above=0.25 cm] at (a.north) {\huge a};
\node[above=0.25 cm] at (b.north) {\huge b};
\node[above=0.25 cm] at (c.north) {\huge c};
\end{tikzpicture}

\end{document}
1
  • Thanks so much I should be able to learn from this.
    – Paul A
    Jun 3 at 13:53
0

Here is another possibility:

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}

\begin{document}
    % size of the squares: 1x1
    \begin{tikzpicture}[
        line/.style={
            blue!10!gray,
            line width=4
        }
    ]

        % border
        \draw[line] (0,1) rectangle (3,0);

        % vertical lines
        \foreach \x in {1,2} {
            \draw[line] (\x,0) -- (\x,1);
        }

        % oblique lines
        \foreach \i in {1,2,3} {
            \draw[line] (\i,1) -- (\i-2,-1);
        }

        % place the nodes a, b and c
        \foreach \nodeText [count=\c] in {a,b,c} {
            \node[font=\huge, anchor=mid] at (\c-.5,1.3) {\nodeText};
        }
    \end{tikzpicture}

    % size of the squares: 2x2
    \begin{tikzpicture}[
        line/.style={
            blue!10!gray,
            line width=4
        }
    ]

        % border
        \draw[line] (0,2) rectangle (6,0);

        % vertical lines
        \foreach \x in {2,4} {
            \draw[line] (\x,0) -- (\x,2);
        }

        % oblique lines
        \foreach \i in {2,4,6} {
            \draw[line] (\i,2) -- (\i-3,-1);
        }

        % place the nodes a, b and c
        \foreach \nodeText [count=\c] in {a,b,c} {
            \node[font=\huge, anchor=mid] at (\c*2-1,2.3) {\nodeText};
        }
    \end{tikzpicture}
\end{document}

3 by 1 grid (squares 1x1) 3 by 1 grid (squares 2x2)

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.