Thursday, April 10, 2014

Scale one TikZ scope to the width of another scope

I came across the problem that I needed to have two TikZ scopes scaled to the same width. Apparently, there is no option to scale a scope to an absolute width (or even better to another scope). In general, one could use two separate tikzpictures and use resizebox to get these tikzpictures to the same width. This works well as long as one does not refer to coordinates of one of these two tikzpictures, e.g. in order to draw a line from a node in one of the tikzpictures (or originally scope) to a node in the other one, as resizebox obviously cannot change the coordinates within a tikzpicture.

This problem frustrated me quite a while, but I came up with a somewhat hacky solution today, which includes "manually" determining the ratio of the two scopes in question and scaling one of the scopes accordingly. tex code is included on the corresponding tex.stackexchange post.

In the following image, the original scopes had a ratio as shown in the image and are scaled to the same width. There is no problem with drawing a line from circle1.east to circle2.east, as all scopes are within the same tikzpicture and there cannot be any confusion about the coordinates.

No comments:

Post a Comment