TransWikia.com

Rectangle inside a rectangle

TeX - LaTeX Asked by Delan on May 4, 2021

I need to get what’s on the picture:

enter image description here

MWE

documentclass[10pt,a4paper]{article}
usepackage{tikz}

begin{document}

begin{tikzpicture}

newcommand* mylengthA {3}
newcommand* mylengthW {0.5}
newcommand* mylengthG {0.5}


fill [blue] (0,0) rectangle (mylengthA, mylengthA);
fill [white]
  (mylengthW,mylengthW) rectangle
  (mylengthA - mylengthW,mylengthA - mylengthW);
fill [yellow]
  (0,mylengthA/2 + mylengthG/2) rectangle +(mylengthW,-mylengthG);
end{tikzpicture}

end{document}

One Answer

You can use plotmarks and scatter them around as you like:

documentclass[10pt,a4paper]{article}
usepackage{tikz}
usetikzlibrary{plotmarks}

begin{document}
    
begin{tikzpicture}
    pgfsetplotmarksize{1.5ex}

    draw[very thick] (0,0) rectangle (10,10);
    draw[very thick,dashed] (2,2) rectangle (8,8);
    
    %points
    node[green] at (1,2) {pgfuseplotmark{*}};
    node[green] at (8.5,8.5) {pgfuseplotmark{*}};
    
    %diamonds
    node[red] at (3,3) {pgfuseplotmark{diamond*}};
    node[red] at (4,5) {pgfuseplotmark{diamond*}};
    


end{tikzpicture}
    
end{document}

enter image description here

Correct answer by Roland on May 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP