previous   Text Transformation MatrixTeX/LaTeX   next


Anchor

For a , the anchor is used to determine where the text should be positioned along the underlying path. Changing the anchor for a text-path will change the way it is displayed in Jpgfdraw (as illustrated in Figure 8.10). For a , the anchor is only used when you export the image to a LaTeX file and changing it will not change the way the text area is displayed in Jpgfdraw.

If you export your image to a LaTeX file, the font used in the document is unlikely to completely match the font used in Jpgfdraw. As a result, text may appear wider or narrower in the resulting LaTeX document than in the image displayed in Jpgfdraw. This may result in the text appearing as though it has shifted position. (Particularly when the contains LaTeX commands.) To reduce this effect, you can specify what part of the text should be considered as the anchor. To illustrate this, consider the image shown in Figure 9.20. An image was created in Jpgfdraw containing some text bordered by a rectangle with an additional line along the text area's baseline: Figure 9.20(a) shows how the image appears in Jpgfdraw. The font used is the generic Java serif font and the text takes up the entire box. The image was then exported to a LaTeX file with various anchor settings. The LaTeX document set the Roman font via:

\usepackage{mathptmx}

This is a slightly narrower font than the Java font used in Jpgfdraw, so the text no longer fills the box. In Figure 9.20(b), the anchor was set to (left, base); in Figure 9.20(c), the anchor was set to (center, base); in Figure 9.20(d), the anchor was set to (right, base). Notice that the base line for the text remains as it was in Jpgfdraw, but the horizontal placement of the text varies.

In this example, the height of the text in the LaTeX document is only slightly smaller than that of the Java font, so the vertical anchor setting does not make that much difference, but there is still a slight shift: in Figure 9.20(e), the anchor was set to (left, bottom); in Figure 9.20(f), the anchor was set to (left, center); in Figure 9.20(g), the anchor was set to (left, top).

   
 anchor  
 (a)  
   
 anchorleftbase anchorcentrebase anchorrightbase  
 (b) (c) (d)  
   
 anchorleftbottom anchorleftcentre anchorlefttop  
 (e) (f) (g)  
Figure 9.20: The effect of converting from Java fonts to TeX fonts: (a) image in Jpgfdraw using the generic Java serif font. The image was then exported to a LaTeX document with the anchor set to: (b) left, base; (c) center, base; (d) right, base; (e) left, bottom; (f) left, center; (g) left, top.

Note that in the above example, the LaTeX document used a scalable font (via the mathptmx package). The default Computer Modern font is not scalable. It is therefore possible that the required size is not available, in which case TeX will substitute the closest available font size. For example, in Figure 9.21, the image created in the previous example is again illustrated with anchor at (left, base). Figure 9.21(a) shows the original image in Jpgfdraw using the Java generic serif font; Figure 9.21(b) shows the image exported to a LaTeX document that uses the mathptmx package; Figure 9.21(c) shows the image exported to a LaTeX document that uses the default Computer Modern font. The large font size (40) is not available in the Computer Modern font, so the closest available font size is used instead, which in this example has resulted in a significant change in size.

   
 anchor anchorleftbase anchorcmr  
 (a) (b) (c)  
Figure 9.21: The font used by the LaTeX document may result in considerable differences from the original image: (a) image in Jpgfdraw; (b) image in LaTeX document using mathptmx package; (c) image in LaTeX document using non-scalable Computer Modern font.

As mentioned earlier, if a contains LaTeX commands, this may also result in a horizontal or vertical shift. Consider an image that contains some maths. Figure 9.22(a) shows the image as it appears in Jpgfdraw. The red line path is aligned along the left edge and along the baseline of the text. The text area has been assigned the following alternative text to be used when exporting to a LaTeX file:

$f(x) = \frac{(x-a_1)^2}{a_2}$
Figure 9.22(b) shows how the image appears in a LaTeX document when the anchor is set to (left, base), and Figure 9.22(c) shows how the image appears in a LaTeX document when the anchor is set to (left, bottom).

   
 anchorfracexa anchorfracexb anchorfracexc  
 (a) (b) (c)  

   
 anchorfracexd  
 (d)  

Figure 9.22: Text area containing maths: (a) image in Jpgfdraw; (b) image as it appears in a LaTeX document with anchor set to (left, base); (c) image as it appears in a LaTeX document with the anchor set to (left, bottom); (d) text area contents.

The default anchor is (left, base). This can be changed using the Edit->Text->Font Style->Anchor menu. The sample panel will display a small red dot to indicate the position of the anchor. If you enable the ||, the anchor will be changed when you || groups containing .

Note that if the text area is transformed then the anchor will have the same transformation. See, for example, Figure 9.23.

   
 anchortransformed  
 (a)  
   
 anchortransformedleft anchortransformedcentre anchortransformedright  
 (b) (c) (d)  
Figure 9.23: The text area's transformation matrix will also be applied to the anchor: (a) original image in Jpgfdraw. The image was then exported to a LaTeX file with anchor: (b) left, base; (c) center, base; (d) right, base.

See also:


previous   Text Transformation MatrixTeX/LaTeX   next