tikzDevice/0000755000176000001440000000000013676564622012424 5ustar ripleyuserstikzDevice/NAMESPACE0000654000176000001440000000253613522525001013624 0ustar ripleyusers# Generated by roxygen2: do not edit by hand S3method(drawDetails,tikz_annotation) S3method(drawDetails,tikz_coord) S3method(drawDetails,tikz_node) S3method(format,ENV_VAR) S3method(format,OPTION) S3method(format,PATH) export(anyMultibyteUTF8Characters) export(getLatexCharMetrics) export(getLatexStrWidth) export(grid.tikzAnnotate) export(grid.tikzCoord) export(grid.tikzNode) export(gridToDevice) export(sanitizeTexString) export(setTikzDefaults) export(tikz) export(tikzAnnotate) export(tikzAnnotateGrob) export(tikzCompilerInfo) export(tikzCoord) export(tikzCoordGrob) export(tikzNode) export(tikzNodeGrob) export(tikzTest) importFrom(filehash,dbCreate) importFrom(filehash,dbExists) importFrom(filehash,dbFetch) importFrom(filehash,dbInit) importFrom(filehash,dbInsert) importFrom(grDevices,as.raster) importFrom(grDevices,dev.cur) importFrom(grDevices,dev.list) importFrom(grDevices,dev.off) importFrom(grDevices,png) importFrom(graphics,grconvertX) importFrom(graphics,grconvertY) importFrom(graphics,par) importFrom(graphics,plot.new) importFrom(graphics,rasterImage) importFrom(grid,convertX) importFrom(grid,convertY) importFrom(grid,current.transform) importFrom(grid,drawDetails) importFrom(grid,grid.draw) importFrom(grid,grob) importFrom(grid,unit) importFrom(stats,complete.cases) importFrom(utils,packageVersion) useDynLib(tikzDevice, .registration = TRUE) tikzDevice/man/0000755000176000001440000000000013522460417013162 5ustar ripleyuserstikzDevice/man/anyMultibyteUTF8Characters.Rd0000654000176000001440000000227713476231116020617 0ustar ripleyusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/deviceUtils.R \encoding{UTF8} \name{anyMultibyteUTF8Characters} \alias{anyMultibyteUTF8Characters} \title{Check If a String Contains Multibyte UTF-8 characters} \usage{ anyMultibyteUTF8Characters(string, encoding = "UTF-8") } \arguments{ \item{string}{A character vector of length 1 (a string).} \item{encoding}{Unused.} } \value{ A boolean value } \description{ This function is used by tikzDevice to check if an incoming string contains multibyte UTF-8 characters } \details{ This function searches through the characters in the given string, if any of the characters in the string are more than one byte then the function returns \code{TRUE} otherwise it returns \code{FALSE}. The function will assume an input encoding of UTF-8 but will take any specified encoding into account and will convert from the specified encoding to UTF-8 before doing any checks } \examples{ # TRUE anyMultibyteUTF8Characters('R is GNU ©, but not ®') # FALSE anyMultibyteUTF8Characters('R is GNU copyright but not restricted') } \seealso{ \code{\link[=tikz]{tikz()}} } \author{ Cameron Bracken \email{cameron.bracken@gmail.com} } \keyword{character} tikzDevice/man/sanitizeTexString.Rd0000654000176000001440000000440013476231116017146 0ustar ripleyusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/sanitizeTexString.R \name{sanitizeTexString} \alias{sanitizeTexString} \title{Replace LaTeX Special Characters in a String} \usage{ sanitizeTexString(string, strip = getOption("tikzSanitizeCharacters"), replacement = getOption("tikzReplacementCharacters")) } \arguments{ \item{string}{A character vector of length 1 (a string).} \item{strip}{A character vector of single characters to search for.} \item{replacement}{A character vector of replacement values.} } \value{ \item{sanitizedString}{A character vector of length 1 with all special characters replaced.} } \description{ This function is used by tikzDevice when \code{sanitize = TRUE} to replace special LaTeX characters (such as the comment character %) in plotting text where the user does not have direct control over the generated text. } \details{ \code{sanitizeTexString()} searches character by character through a string replacing each occurrence of a special character contained in \code{strip[i]} with the corresponding replacement value in \code{replacement[i]}. tikzDevice calls back this function for every piece of text when the sanitize option is TRUE. See \code{\link[=tikz]{tikz()}} for more information on the default special characters and replacement values. By default, \code{tikzSanitizeCharacters} replaces the following characters: \itemize{ \item \verb{\%} \item \verb{$} \item \verb{\}} \item \verb{\{} \item \verb{^} \item \verb{_} \item \verb{#} \item \verb{&} \item \verb{~} } With the contents of \code{tikzReplacementCharacters}: \itemize{ \item \verb{\\\%} \item \verb{\\$} \item \verb{\\\}} \item \verb{\\\{} \item \verb{\\^{}} \item \verb{\\_{}} \item \verb{\\#} \item \verb{\\&} \item \verb{\char`\~} } These defaults may be adjusted using the \code{\link[=options]{options()}} function. } \examples{ # Be careful with sanitizing, it may lead to unexpected behavior. # For example, we may want -1 to be a superscript it gets # sanitized away with the other default special characters. # The string appears in LaTeX exactly as shown. \dontrun{ sanitizeTexString('10\\\% of 10$ is 10^\\{-1\\}$') } } \seealso{ \code{\link[=tikz]{tikz()}} } \author{ Cameron Bracken \email{cameron.bracken@gmail.com} } \keyword{character} tikzDevice/man/tikzAnnotate.Rd0000654000176000001440000001411013476231116016122 0ustar ripleyusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/tikzAnnotate.R \name{tikzAnnotate} \alias{tikzAnnotate} \alias{tikzNode} \alias{tikzCoord} \alias{tikzAnnotateGrob} \alias{tikzNodeGrob} \alias{tikzCoordGrob} \alias{grid.tikzAnnotate} \alias{grid.tikzNode} \alias{grid.tikzCoord} \title{Add Custom TikZ Code to an Active Device} \usage{ tikzAnnotate(annotation, checkstate = TRUE) tikzNode(x = NULL, y = NULL, opts = NULL, name = NULL, content = NULL, units = "user") tikzCoord(x, y, name, units = "user") tikzAnnotateGrob(annotation) tikzNodeGrob(x = NULL, y = NULL, opts = NULL, name = NULL, content = NULL, units = "native") tikzCoordGrob(x, y, name, units = "native") grid.tikzAnnotate(annotation, draw = TRUE) grid.tikzNode(x = NULL, y = NULL, opts = NULL, name = NULL, content = NULL, units = "native", draw = TRUE) grid.tikzCoord(x, y, name, units = "native", draw = TRUE) } \arguments{ \item{annotation}{A character vector, one element per line to be added to the open tikz device.} \item{checkstate}{A logical, whether to "flush" the device state prior to writing the \code{annotation}.} \item{x}{numeric, x location for a named coordinate in user coordinates} \item{y}{numeric, y location for a named coordinate in user coordinates} \item{opts}{A character string that will be used as options for a \code{node}. See the "Nodes and Edges" section of the TikZ manual for complete details.} \item{name}{Optional character string that will be used as a name for a \code{coordinate} or \code{node}. Other TikZ commands can use this name to refer to a location in a graphic.} \item{content}{A character string that will be used as the content to be displayed inside of a \code{node}. If left as \code{NULL} a \code{coordinate} will be created instead of a \code{node}. If a \code{node} with empty content is truely desired, pass an empty string \code{""}.} \item{units}{Character string specifying the unit system associated with \code{x} and \code{y}. See \code{\link[=grconvertX]{grconvertX()}} for acceptable units in base graphics and \code{\link[=unit]{unit()}} for acceptable units in grid graphics.} \item{draw}{A logical value indicating whether graphics output should be produced.} } \value{ Nothing returned. } \description{ These functions allow custom (LaTeX) commands to be added to the output of an active tikzDevice. } \details{ \code{tikzAnnotate} is intended to allow the insertion of arbitrary TikZ commands into the output stream of a graphic. For LaTeX commands that reference specific locations in an R plot, coordinates must be specified in "device units" which for \code{tikz} output are TeX points relative to the lower left corner of the device canvas. Functions such as \code{\link[=grconvertX]{grconvertX()}} and \code{\link[=gridToDevice]{gridToDevice()}} can help make the necessary conversions for base and grid graphics. The \code{tikzNode} and \code{tikzCoord} functions automatically perform unit conversions acording the the value of their \code{units} parameters. \code{tikzNode} is a wrapper for \code{tikzAnnotate} that inserts TikZ \code{\\node} or \code{\\coordinates} commands into the output. The difference between a node and a coordinate is the presence of a \code{content} section that can contain arbitrary LaTeX text. This is useful for adding textual annotations at specific locations in a TikZ graphic. The \code{tikzCoord} function is a wrapper for \code{tikzNode} that simplifies the task of inserting named coordinates. Additionally, the \code{tikzAnnotateGrob}, \code{tikzNodeGrob} and \code{tikzCoordGrob} functions are supplied for creating grid objects or "\code{\link[=grob]{grob()}}s" that can be used in Grid graphics. High level wrapper functions \code{grid.tikzAnnotate}, \code{grid.tikzNode} and \code{grid.tikzCoord} are also supplied which creat and render a \code{grob} in one step. See the TikZ Device vignette for more information and examples and the TikZ manual for the definitive reference on what is possible with nodes. } \examples{ \dontrun{ ### Example 1: Annotations in Base Graphics # Load some additional TikZ libraries tikz("annotation.tex",width=4,height=4, packages = c(getOption('tikzLatexPackages'), "\\\\usetikzlibrary{decorations.pathreplacing}", "\\\\usetikzlibrary{positioning}", "\\\\usetikzlibrary{shapes.arrows,shapes.symbols}") ) p <- rgamma (300 ,1) outliers <- which( p > quantile(p,.75)+1.5*IQR(p) ) boxplot(p) # Add named coordinates that other TikZ commands can hook onto tikzCoord(1, min(p[outliers]), 'min outlier') tikzCoord(1, max(p[outliers]), 'max outlier') # Use tikzAnnotate to insert arbitrary code, such as drawing a # fancy path between min outlier and max outlier. tikzAnnotate(c("\\\\draw[very thick,red,", # Turn the path into a brace. 'decorate,decoration={brace,amplitude=12pt},', # Shift it 1em to the left of the coordinates 'transform canvas={xshift=-1em}]', '(min outlier) --', # Add a node with some text in the middle of the path 'node[single arrow,anchor=tip,fill=white,draw=green,', 'left=14pt,text width=0.70in,align=center]', '{Holy Outliers Batman!}', '(max outlier);')) # tikzNode can be used to place nodes with customized options and content tikzNode( opts='starburst,fill=green,draw=blue,very thick,right=of max outlier', content='Wow!' ) dev.off() ### Example 2: Annotations in Grid Graphics library(grid) tikz("grid_annotation.tex",width=4,height=4, packages = c(getOption('tikzLatexPackages'), "\\\\usetikzlibrary{shapes.callouts}") ) pushViewport(plotViewport()) pushViewport(dataViewport(1:10, 1:10)) grid.rect() grid.xaxis() grid.yaxis() grid.points(1:10, 1:10) for ( i in seq(2,8,2) ){ grid.tikzNode(i,i,opts='ellipse callout,draw,anchor=pointer',content=i) } dev.off() } } \seealso{ \code{\link[=grconvertX]{grconvertX()}} \code{\link[=grconvertY]{grconvertY()}} \code{\link[=gridToDevice]{gridToDevice()}} \code{\link[=unit]{unit()}} \code{\link[=tikz]{tikz()}} } \author{ Cameron Bracken \href{mailto:cameron.bracken@gmail.com}{cameron.bracken@gmail.com} and Charlie Sharpsteen \email{source@sharpsteen.net} } \keyword{annotation} \keyword{device} \keyword{tikz} tikzDevice/man/getLatexStrWidth.Rd0000654000176000001440000000616513476231116016730 0ustar ripleyusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/latexStrWidth.R \name{getLatexStrWidth} \alias{getLatexStrWidth} \alias{getLatexCharMetrics} \title{Obtain Font Metrics from LaTeX} \usage{ getLatexStrWidth(texString, cex = 1, face = 1, engine = getOption("tikzDefaultEngine"), documentDeclaration = getOption("tikzDocumentDeclaration"), packages, verbose = interactive(), diagnose = FALSE) getLatexCharMetrics(charCode, cex = 1, face = 1, engine = getOption("tikzDefaultEngine"), documentDeclaration = getOption("tikzDocumentDeclaration"), packages, verbose = interactive()) } \arguments{ \item{texString}{An arbitrary string for which the width is to be calculated. May contain LaTeX markup.} \item{cex}{a real number that specifies a scaling factor that is to be applied to device output.} \item{face}{an integer in the range \code{1:5} that specifies the font face to use. See \link{par} for details.} \item{engine}{a string specifying which TeX engine to use. Possible values are 'pdftex', 'xetex' and 'luatex'. See the Unicode section of \link{tikzDevice-package} for details.} \item{documentDeclaration}{See the sections "Options That Affect Package Behavior" and "Font Size Calculations" of \link{tikzDevice-package} for more details.} \item{packages}{See the section "Options That Affect Package Behavior" of \link{tikzDevice-package}.} \item{verbose}{A logical value indicating whether diagnostic messages are printed when measuring dimensions of strings. Defaults to \code{TRUE} in interactive mode only, to \code{FALSE} otherwise.} \item{diagnose}{pass \code{TRUE} to print detailed error information.} \item{charCode}{an integer that corresponds to a symbol in the ASCII character table under the Type 1 font encoding. All numeric values are coerced using \code{as.integer()}. Non-numeric values will not be accepted.} } \value{ \item{getLatexStrWidth}{The width of \code{texString} in points.} \item{getLatexCharMetrics}{A numeric vector holding ascent, descent and width. Values should all be nonnegative.} } \description{ These functions calculate the width of a character or string as it would appear after being compiled by LaTeX. } \details{ These functions are used internally by the \code{tikz} device for proper string placement in graphics. Both functions check to see if metrics exist in a global or temporary dictionary (as defined in \code{options('tikzMetricsDictionary')}) and if so will pull the metrics from there. If the dictionary does not exist, then a temporary one is created for the current R session. Metrics are calculated via \code{system} calls to LaTeX compilers. Querying compilers to calculate metrics is expensive and so we strongly recommend setting \code{options('tikzMetricsDictionary') <- '/path/to/dictionary'} to create a global dictionary. } \examples{ getLatexStrWidth('{\\\\\\\\tiny Hello \\\\\\\\LaTeX!}') # Calculate ascent, descent and width for "A" getLatexCharMetrics(65) } \references{ PGF Manual } \author{ Charlie Sharpsteen \email{source@sharpsteen.net} and Cameron Bracken \email{cameron.bracken@gmail.com} } \keyword{character} \keyword{metrics} \keyword{string} tikzDevice/man/tikzDevice-package.Rd0000654000176000001440000001471313522460417017152 0ustar ripleyusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/tikzDevice-package.R \docType{package} \name{tikzDevice-package} \alias{tikzDevice-package} \alias{tikzDevice} \title{Support for native LaTeX output of R graphics} \description{ The tikzDevice package implements the \code{\link[=tikz]{tikz()}} ouput device which generates R graphics in a LaTeX friendly format. LaTeX handles the typesetting of all text in graphics generated by \code{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 \strong{LaTeX mathematics can be typeset directly into labels and annotations}. } \section{Options That Affect Package Behavior}{ The \pkg{tikzDevice} package is currently influenced by a number of global options that may be set in scripts, from the console or in a \code{.Rprofile} file. All of the options can be set by using \code{options(