4

I have want to draw square-tile in tikz like the following picture: iwant

I use matrix styles and put thing in.

My code:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{sq} = [rectangle, minimum width=0.7cm, minimum height=0.7cm, text centered, draw=black ]
\tikzstyle{sqvec} = [matrix,draw=black,thick] 

\begin{document}
\begin{tikzpicture}
\node [sqvec] (v7) at (2.5,4) {
\node[sq] {}; &\node[sq] {}; &\node[sq] {}; \\
\node[sq] {}; &\node[sq] {}; &\node[sq] {}; \\
};      
\end{tikzpicture}
\end{document}

And here is what I got:

igot

I want to get rid of the second outer border and make inner border have equal thickness with outer border.

1
  • 1
    \tikzstyle{sqvec} = [matrix,thick], but for more nice result you need to tweek your nodes' settings.
    – Zarko
    Aug 5 '17 at 14:12
5

enter image description here

for above image the solution given in my comment should be replaced with more sophisticated way:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{matrix}

\begin{document}
    \begin{tikzpicture}
\matrix (m) [matrix of nodes,
             nodes={minimum size=7mm, draw, outer sep=0pt},
             nodes in empty cells,
             column sep=-\pgflinewidth, row sep=-\pgflinewidth
             ]
{
    &   &   \\
    &   &   \\
};
    \end{tikzpicture}
\end{document}

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.