Home > tikz pgf > How Do I Draw Two Overlapping Rectangles?

How Do I Draw Two Overlapping Rectangles?

April 16Hits:2
Advertisement

I'm working on an interaction diagram for a programming design course. For sets of objects, I am required to draw overlapping rectangles, roughly as such:

How Do I Draw Two Overlapping Rectangles?

There was a post on overlapping fills that seems pretty close to what I want, but I couldn't figure out how to use the style of my other rectangles.

Here's a minimal version of what I have:

\documentclass{article}  \usepackage{amssymb} \usepackage{tikz} \usetikzlibrary{positioning}  \title{Interaction Diagram - Add Book} \author{}  \begin{document}  \begin{center} \begin{tikzpicture}[   auto,   block/.style = {     minimum width = 9em,     rectangle,     draw=black,     align=center,     rounded corners   } ] \node[block, below = 2cm of start]      (controller) {\underline{: SystemController}}; \node[block, below = 2cm of controller] (system)     {\underline{: System}};   % the following line should be the doubled up rectangles. \node[block, below = 2cm of system] (books) {Books};  \end{tikzpicture} \end{center} \end{document} 

Answers

Here is one way without tikz. The \rule dimensions and the first argument of \stackengine will allow different box sizes and offsets.

In this case, the boxes are 30pt x 30pt, with a 4pt horizontal offset and 3pt vertical offset. The box rule thickness is the default \fboxrule.

\documentclass[12pt]{article}
\usepackage{xcolor,stackengine}
\fboxsep=-\fboxrule
\begin{document}
\stackengine{3pt}{\rule{4pt}{0pt}\fbox{\textcolor{white}{\rule{30pt}{30pt}}}}
  {\fbox{\textcolor{white}{\rule{30pt}{30pt}}}}
  {O}{l}{F}{F}{L}
\end{document}

How Do I Draw Two Overlapping Rectangles?

I assume, that actually you like to have something like this:

How Do I Draw Two Overlapping Rectangles?

or

How Do I Draw Two Overlapping Rectangles?

or

How Do I Draw Two Overlapping Rectangles?

For the last picture I use the following code:

\documentclass[tikz,
               border= 3mm]{standalone}
\usetikzlibrary{positioning,shadows}

\begin{document}
\begin{tikzpicture}[
book/.style = {rectangle, draw, rounded corners, fill= white,
               text width=9em, align= center,
               copy shadow={draw, fill=gray,
                            shadow xshift=0.5mm, shadow yshift=-0.5mm}
               }
                    ]
\node[book] (books) {Books};
\end{tikzpicture}
\end{document}

In code I use TikZ library shadows.

Tags:tikz pgf

Related Articles

  • How Do I Draw Two Overlapping Rectangles?

    How Do I Draw Two Overlapping Rectangles?April 16

    I'm working on an interaction diagram for a programming design course. For sets of objects, I am required to draw overlapping rectangles, roughly as such: There was a post on overlapping fills that seems pretty close to what I want, but I couldn't fi

  • TikZ: Draw the smallest rectangle containing given points with sides parallel to coordinate axes

    TikZ: Draw the smallest rectangle containing given points with sides parallel to coordinate axesSeptember 24

    I need a TikZ macro to draw the smallest rectangle around a list of points, with sides parallel to the coordinate axes. In a perfect world it would work with any number of points greater than 1, but I would be happy if it just worked with 3. The poin

  • Drawing a 3x2 rectangle

    Drawing a 3x2 rectangleFebruary 17

    I am trying to draw a 3x2 rectangle. I am not sure if multipart rectangle can do it, but it seems that multipart can only do one-dimensional arrays. I tried matrix, but then I cannot get the lines in between cells or around the rectangle. I need to p

  • Drawing a hollow rectangle of rows and column provided by the console applicationMarch 1

    This question was put forward by my senior to draw a hollow rectangle in C#, and with the condition that the rows and column would be specified by the user. I was stuck at first, but tried to code and after several hours I realized how it would be do

  • Algorithm for merging overlapping rectanglesAugust 23

    The following code is part of an application I maintain that has a VT100/Xterm style graphical user interface that is implemented using text (Think Midnight Commander. Retro, I know.) Part of the code involves producing collections of rectangles that

  • Overlapping rectangles

    Overlapping rectanglesSeptember 16

    I received the following question in a technical interview today (for a devops/SRE position): Write a function which returns true if the two rectangles passed to it as arguments would overlap if drawn on a Cartesian plane. The rectangles are guarante

  • Draw line to rectangle

    Draw line to rectangleApril 27

    I want to connect a node with an edge of a complex shape. I am just able to connect it with the center. I have the following code: \documentclass[tikz]{standalone} \usetikzlibrary{positioning} \usetikzlibrary{shapes} \usetikzlibrary{calc} \usetikzlib

  • Drawing a colored rectangle on-screenAugust 3

    I have made my first program that draws a colored rectangle on-screen. I want to know the best practices of making OpenGL and GLSL programs. #include <GL/glew.h> #include <SFML/Window.hpp> #include <iostream> #include <string> #inc

  • Multiple overlapping rectanglesNovember 28

    I have a collision method where the parameters for the method are the rectangle of the player and a list with the rectangles of the tiles. I work with booleans like bLeft, bRight,... and this creates a problem if my player collides with two tiles at

  • LibGDX - How to draw a filled rectangle behind a text?January 10

    I'm new in LibGDX and I want to create a grid based game. Every square will have a rectangle and a text and the background color of the rectangles can change during the game. The problem is when I draw a filled rectangle with ShapeRenderer, it always

  • How can I draw a selection rectangle on QScrollArea?

    How can I draw a selection rectangle on QScrollArea?February 4

    I have created an Image Viewer application that opens and saves an image and load the image on QLabel,then I created a ScrollArea to scroll for large images, in my second step I am trying to draw a selection rectangle to select a specific sub area ,

  • How to draw a filled rectangle without a border using TikZ?November 13

    Method 1: \draw [fill=orange] (0.1,0.1) rectangle (0.2,0.2); For the line above, by default, the filled orange rectangle will have a black border. Method 2: \draw [fill=orange,orange] (0.1,0.1) rectangle (0.2,0.2); With this line, the border color wi

  • how to draw two connected rectangles

    how to draw two connected rectanglesApril 17

    How can I draw two rectangles (or two shapes in general) so that they touch each other. Below is the minimum working example. \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{shapes,positioning} \begin{document} \begin{tikzpicture} \node[

  • Tikz - Thick line by overlapping rectangles - How to improve the diagram

    Tikz - Thick line by overlapping rectangles - How to improve the diagramNovember 18

    I create my diagram with the following code. \documentclass{article} % \usepackage[ngerman]{babel} \usepackage{tikz} \usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,% decorations.pathreplacing,decorations.pathmorphing,shapes,% m

  • How to draw a decorated rectangle with rounded corners?

    How to draw a decorated rectangle with rounded corners?December 21

    As the title says, I was trying to draw a rectangle with rounded corners, and then decided it needed decorating. Well, the result looks awesome, but isn't really what I had in mind. a) What happened? b) How do I do it properly? \documentclass[a4paper

  • Prevent drawing of overlapping point symbols - ArcGIS Server/Javascript API

    Prevent drawing of overlapping point symbols - ArcGIS Server/Javascript APIJuly 24

    Is there any way in ArcGIS to prevent symbols from being drawn when they overlap each other? I know this is possible for Labels using Placement Properties/Label Weight, but I can't seem to find corresponding functionality for symbology. The resulting

  • How draw dynamic empty rectangle over a bitmap?

    How draw dynamic empty rectangle over a bitmap?October 3

    I am trying to make a cookie cutter that will extract a small square from a much larger bitmap with a click of the mouse. The LocatorPane appears to be a useful way to move the cookie cutter around, but I'm not having much luck in drawing the small d

  • draw dotted/dashed rectangles in Eagle schematicNovember 21

    I'm trying to draw some dashed/dotted rectangles in Eagle schematic to annotate functional groups like in this link I tried to draw rectangle and switch it to different types e.g. symbol, net, info... all failed so far --------------Solutions--------

  • How to draw a thin rectangle

    How to draw a thin rectangleFebruary 2

    I was trying to draw a rectangle like this (there would be only one letter per row in the rectangle). But none of \\, \linebreak, \newline seems to work. How can I do this? Well, I tried this: \documentclass{standalone} \usepackage{tikz} \begin{docum

  • How to draw 3 overlapping circles with different colors?

    How to draw 3 overlapping circles with different colors?June 1

    Is there a free software to draw following in ubuntu? How to color the overlap zone? I am not able to figure this out in GIMP. --------------Solutions------------- You can use Inkscape. Basically, you'll have to break the circles into several parts,

Copyright (C) 2018 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.428 s.