getLatexStrWidth {tikzDevice}R Documentation

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.

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.

Value

width The width of texString in point size.

Note

tikzDevice tries very hard when it is loaded to find a working latex or pdflatex command. If it is successful the command is set in options('tikzLatex'), otherwise this function will fail.

Author(s)

Charlie Sharpsteen source@sharpsteen.net and Cameron Bracken cameron.bracken@gmail.com

See Also

tikz, getLatexCharMetrics

Examples

        getLatexStrWidth('{\\tiny Hello \\LaTeX!}')

[Package tikzDevice version 0.4.8 Index]