Learn R Programming

tikzDevice (version 0.6.0)

tikzDevice-package: Support for native LaTeX output of R graphics

Description

The tikzDevice package implements the tikz ouput device which generates R graphics in a LaTeX friendly format. LaTeX handles the typesetting of all text in graphics generated by tikz. This allows for seamless integration between these graphics and documents that are also being typeset by LaTeX. Using LaTeX to generate graph text also means that LaTeX mathematics can be typeset directly into labels and annotations

Arguments

Options That Affect Package Behavior

The tikzDevice package is currently influenced by a number of global options that may be set in R

code

tikz

describe

  • tikzDefaultEngineSpecifies which typesetting engine functions in the tikzDevice package will prefer. Current possible values are pdftex or xetex which will respectively trigger the use of the pdflatex and xelatex compilers.
  • tikzLatexSpecifies the location of the LaTeX compiler to be used by tikzDevice. Setting this option may help the package locate a missing compiler. The default is searched for when the package is loaded, otherwise it can be set manually. This option may be set as follows: options( tikzLatex = '/path/to/latex/compiler' ).
  • tikzXelatexFunctions similar to tikzLatex, except this option specifies the location of the XeLaTeX compiler.
  • tikzMetricsDictionaryWhen using the graphics device provided by tikzDevice, you may notice that R
  • appears to ``lag" or ``hang" when commands such as plot() are executed. This is because the device must query the LaTeX compiler for string widths and font metrics. For a normal plot, this may happen dozens or hundreds of times- hence R

item

  • tikzDocumentDeclaration
  • tikzLatexPackages
  • tikzXelatexPackages
  • tikzFooter
  • tikzMetricPackages
  • tikzUnicodeMetricPackages
  • tikzSanitizeCharacters
  • tikzReplacementCharacters
  • tikzRasterResolution
  • tikzPdftexWarnUTF

preformatted

\documentclass[10pt]{article}

Font Size Calculations

The overarching goal of the tikzDevice is to provide seamless integration between text in R

itemize

  • The ``base font size'' specified when the graphics device is created.
  • The ``character expansion factor'' parameter, specified using thecexargument to functions such aspar.
  • The ``font size'' parameter, specified using thepsargument to functions such asparor thefontsizeargument to functions such asgpar.

Unicode

Using tikzDevice functions on strings containing Unicode (multibyte) characters requires special consideration. The primary reason for this is that pdftex, the typesetting engine most commonly used to compile LaTeX documents, has no native support for Unicode. Recently, two new engines have become widely available that do support Unicode natively. These engines are:

  • Thexetexengine which has been a part of standard TeX distributions since TeX Live 2007 and MiKTeX 2.7.
  • Theluatexengine which is a direct sucessor topdftex. LuaTeX is still considered `beta' software (as of spring 2011) but has been included in standard TeX distributions since TeX Live 2008 and MiKTeX 2.9.

As of Version 0.6.0, the tikzDevice package includes support for the xetex engine provided a recent version of TeX Live or MiKTeX is available.

The tikzDevice defaults to using the pdftex engine, but this may be changed by setting an option: option(tikzDefaultEngine = 'xetex'). When working with text that contains Unicode characters, we strongly reccomend switching to the xetex engine and the package will produce warning messages when multibyte characters are sent to the pdftex engine. Users who find these warnings annoying may disable them by setting options(tikzPdftexWarnUTF = FALSE) as it is possible to send Unicode information to the pdftex engine with the following caveats:

  • The task of determining the proper mix of LaTeX packages required to supply glyphs for Unicode characters is left entirely up to the user.options(tikzLatexPackages)may need to be customized in order to get proper behavior.
  • ThegetLatexCharMetricsfunction will always return 0 for ascent, descent and width when passed a character code outside the range 32--127 when using thepdftexengine.

When using the xetex engine, Unicode support is enabled by loading the LaTeX packages fontspec and xunicode. Using this setup, support for Unicode characters should be limited only by the fonts used in the document. The font selection may be adjusted using options(tikzXelatexPackages).

Details

ll{ Package: tikzDevice Type: Package Version: 0.6.0 Date: 2011-04-13 License: GPL 3.0 or greater LazyLoad: yes }

References

The TikZ and PGF Packages: Manual for version 2.00 http://sourceforge.net/projects/pgf Till Tanatu, February 20, 2008

See Also

tikz