Section 2.1 The <diagram>
element
Every PreFigure XML description is contained within a
<diagram>
element. The required @dimensions
attribute determines the dimensions of the drawing surface in SVG coordinates. For instance, @dimensions="(300, 200)"
sets up a drawing surface that is 300 units wide and 200 units high.Authors may additionally use a
@margins
attribute to add some space around the drawing surface into which some components of the diagram, perhaps a label, may spill. By default, margins are set to 0. However, @margins="5"
adds a margin of 5 units around all four sides of the drawing surface. Specifying @margins="(20, 5, 10, 15)"
adds 20 units to the left, 5 to the bottom, 10 to the right, and 15 to the top.Of course, SVG images scale well so we could, in principle, create diagrams of whatever size we wish and assume they will be scaled appropriately when placed in a surrounding document. However, when an SVG image is scaled, all the dimensions in the image, such as the thickness of lines and the size of labels, are scaled as well. It is therefore a good practice to set the dimensions to something roughly similar to what you hope to see in your document. Declaring that
@dimensions="(300, 300)"
produces an image whose labels closely match the size of surrounding text when included in a PreTeXt document.Similarly, setting the margins to some positive value means that lines drawn on the boundary of the drawing surface are not unintentionally clipped. The diagram shown in Figure 2.1.1 was constructed with
@margins="0"
. Some of the grid lines appear on the boundary of the drawing surface and we only see the half of those lines that are in the drawing surface. This effect is apparent even in lines that are relatively thin.