getLatexStrWidth: Obtain the Width of an Arbitrary LaTeX String
Description
This function calculates the width of a string as it would appear after being compiled by LaTeX.
Usage
getLatexStrWidth( texString, cex=1, face=1 )
Arguments
texString
An arbitrary string for which the width is to be calculated. May contain LaTeX markup.
cex
a real number that specifies a scaling factor that is to be applied to device output.
face
an integer in the range [1-5] that specifies the font face to use. See par for details.
Value
widthThe width of texString in point size.
Details
This function is used internally by the tikz device for proper string placement in graphics. This function first checks to see if the width exists in a global or temporary string width dictionary (as define in options('tikzMetricsDictionary')) and if so will pull the width from there. If the dictionary does not exist then a temporary one for the current R session is created and the string width is calculated via a system call to latex. The calling of latex to calculate a string width is quit expensive and so we strongly recommend setting options('tikzMetricsDictionary') <- /path/to/dictionary to create a global dictionary.