I have two rectangles with stroke width of 2px.
How do I go about putting them side by side such that they share the same adjacent stroke border of 2px?
I tried dragging the rectangles to fit them into the stroke but there is no snapping. Is there a better way to do this?
Draw one rectangle and then draw a 2px line and center it in the rectangle.
Unless there’s some reason you must have two separate rectangles.
(Assumption that all strokes are set to the default stroke alignment, which is centered on their respective paths)
Realistically, if two rectangles are actually butted against each other, there is no variation in the appearance of a stroke….
Yellow boxes are all the same width…. as are the strokes. However this is two separate rectangles.
The key may be to use Outline Mode (View > Outline) to ensure your rectangles actually do butt against each other. Outline mode can be an invaluable feature if you are trying to be precise in positioning. There is simply no way to be as accurate working strictly in Preview Mode.
Because if you have a gap or overlap between the rectangles:
…. and everything is stroked the same color, all you’ll see in Preview Mode (View > Preview) is the apparent “thicker” stroke:
What actually happens is the two strokes overlap each other and are not aligned properly:
So, basically, this issue is ultimately because your two rectangles are not butting against each other.
Correctly aligned objects will have correctly aligned strokes which, when overlapping will not give the appearance of a thicker stroke.
You may also find it helpful to ensure
Use Preview Bounds is not checked in the Preferences. This will allow snapping to use actual object paths for snapping rather than their preview containing the stroke appearance.