Package texpreview. August 15, 2018

Similar documents
Package slickr. March 6, 2018

Package jstree. October 24, 2017

Package datasets.load

Package canvasxpress

Package fastdummies. January 8, 2018

Package regexselect. R topics documented: September 22, Version Date Title Regular Expressions in 'shiny' Select Lists

Package validara. October 19, 2017

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package spelling. December 18, 2017

Package ECctmc. May 1, 2018

Package shinyhelper. June 21, 2018

Package resumer. R topics documented: August 29, 2016

Package docxtools. July 6, 2018

Package pdfsearch. July 10, 2018

Package ezknitr. September 16, 2016

Package pairsd3. R topics documented: August 29, Title D3 Scatterplot Matrices Version 0.1.0

Package robotstxt. November 12, 2017

Package calpassapi. August 25, 2018

Package pkgbuild. October 16, 2018

Package clipr. June 23, 2018

Package knitrprogressbar

Package editdata. October 7, 2017

Package profvis. R topics documented:

Package carbonate. R topics documented: October 14, 2018

Package datapasta. January 24, 2018

Package internetarchive

Package shiny.semantic

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package barcoder. October 26, 2018

Package bigreadr. R topics documented: August 13, Version Date Title Read Large Text Files

Package SEMrushR. November 3, 2018

Package messaging. May 27, 2018

Package shinyfeedback

Package radix. September 17, 2018

Package liftr. R topics documented: May 14, Type Package

Package SASmarkdown. R topics documented: November 30, Version Date Title 'SAS' Markdown

Package BiocStyle. January 26, 2018

Package goodpractice

Package rpostgislt. March 2, 2018

Package autoshiny. June 25, 2018

Package patentsview. July 12, 2017

Package virustotal. May 1, 2017

Package workflowr. July 6, 2018

Package spark. July 21, 2017

Package sessioninfo. June 21, 2017

Package BiocStyle. December 9, 2018

Package data.world. April 5, 2018

Package essurvey. August 23, 2018

Package epitab. July 4, 2018

Package readxl. April 18, 2017

Package RndTexExams. R topics documented:

Package simplecache. August 22, 2017

Package gtrendsr. August 4, 2018

Package condformat. October 19, 2017

Package loggit. April 9, 2018

Package gtrendsr. October 19, 2017

Package strat. November 23, 2016

Package projector. February 27, 2018

Package deductive. June 2, 2017

Package rtika. May 2, 2018

Package rcmdcheck. R topics documented: November 10, 2018

Package librarian. R topics documented:

Package qualmap. R topics documented: September 12, Type Package

Package htmlwidgets. July 10, 2017

Package available. November 17, 2017

Package tfruns. February 18, 2018

Package rprojroot. January 3, Title Finding Files in Project Subdirectories Version 1.3-2

Package sigmanet. April 23, 2018

Package edfreader. R topics documented: May 21, 2017

Package fastqcr. April 11, 2017

Package vdiffr. April 27, 2018

Package tiler. June 9, 2018

Package htmlwidgets. February 25, 2016

Package gifti. February 1, 2018

Package pmatch. October 19, 2018

Package vinereg. August 10, 2018

Package rticles. May 16, Type Package Title Article Formats for R Markdown Version 0.4.1

Package rnn. R topics documented: June 21, Title Recurrent Neural Network Version 0.8.1

Package smapr. October 20, 2017

Package knitrbootstrap

Package lumberjack. R topics documented: July 20, 2018

Package postgistools

Package knitlatex. August 29, 2016

Package repec. August 31, 2018

Package eply. April 6, 2018

Package rsppfp. November 20, 2018

Package rgho. R topics documented: January 18, 2017

Package jdx. R topics documented: January 9, Type Package Title 'Java' Data Exchange for 'R' and 'rjava'

Package AutoDeskR. July 10, 2017

Package censusapi. August 19, 2018

Package d3heatmap. February 1, 2018

Package sfc. August 29, 2016

Package SNPediaR. April 9, 2019

Package jug. April 13, 2017

Package pwrab. R topics documented: June 6, Type Package Title Power Analysis for AB Testing Version 0.1.0

Package GetITRData. October 22, 2017

Package sfdct. August 29, 2017

Package patchdvi. June 9, 2015

Package crossword.r. January 19, 2018

Package ezsummary. August 29, 2016

Transcription:

Type Package Package texpreview August 15, 2018 Title Compile and Preview Snippets of 'LaTeX' in 'RStudio' Version 1.1.5 Date 2018-08-15 Maintainer Jonathan Sidi <yonis@metrumrg.com> Compile and preview snippets of 'LaTeX'. Can be used directly from the R console, from 'RStudio', in Shiny apps and R Markdown documents. Must have 'pdflatex' or 'xelatex' or 'lualatex' in 'PATH'. Depends R (>= 2.3.0) Imports rstudioapi,magick,svgpanzoom,utils,xml2, htmltools, base64enc Suggests magrittr (>= 1.0.1), xtable, shiny, rmarkdown, knitr, testthat, covr License GPL-2 GPL-3 URL https://github.com/metrumresearchgroup/texpreview BugReports https://github.com/metrumresearchgroup/texpreview/issues LazyData false NeedsCompilation no RoxygenNote 6.0.1 Author Jonathan Sidi [aut, cre], Daniel Polhamus [aut] Repository CRAN Date/Publication 2018-08-15 14:20:03 UTC R topics documented: buildusepackage...................................... 2 gettexpackages....................................... 3 texpreview.......................................... 3 tex_opts........................................... 5 Index 7 1

2 buildusepackage buildusepackage Build usepackage command for TeX document input TeX package name and optional package functions to create usepackage call buildusepackage(pkg, options = NULL, uselibrary = NULL, chk.inst = FALSE) Arguments pkg options uselibrary chk.inst character, name of TeX package character, name(s) of options to use in the package character, part of document preamble to specify a uselibrary call related to package logical, invokes a check to see if pkg is currently installed on system (default FALSE) Value if options and uselibrary are NULL (default) then only the call for the package is returned. See the TeX wikibook for more information https://en.wikibooks.org/wiki/latex/document_ Structure#Packages on the usepackage command. If chk.inst finds that the package is not installed on system function returns NULL. character buildusepackage(pkg = 'xcolor') buildusepackage(pkg = 'xcolor',options = 'usenames') #build many at once using mapply geom.opts=c('paperwidth=35cm','paperheight=35cm','left=2.5cm','top=2.5cm') use.opts="\\usetikzlibrary{mindmap,backgrounds}" unlist(mapply(buildusepackage, pkg = list('times','geometry','tikz'), options= list(null,geom.opts,null), uselibrary = list(null,null,use.opts) ))

gettexpackages 3 gettexpackages Get list of TeX packages installed on System Fetch all TeX packages currently installed on system gettexpackages() If OS is Windows function checks against MikTex else function checks against TexLive. Value character ## Not run: head(gettexpackages()) texpreview Render and Preview snippets of TeX in R Viewer input TeX script into the function and it renders a pdf and converts it an image which is sent to Viewer. texpreview(obj, tex_lines = NULL, stem = NULL, filedir = tex_opts$get("filedir"), overwrite = TRUE, margin = tex_opts$get("margin"), imgformat = tex_opts$get("imgformat"), returntype = tex_opts$get("returntype"), resizebox = tex_opts$get("resizebox"), usrpackages = NULL, engine = tex_opts$get("engine"), cleanup = tex_opts$get("cleanup"), keep_pdf = FALSE, tex_message = FALSE, density = tex_opts$get("density"), print.xtable.opts = tex_opts$get("print.xtable.opts"), opts.html = tex_opts$get("opts.html"),...)

4 texpreview Arguments obj tex_lines stem filedir overwrite margin imgformat returntype resizebox usrpackages engine cleanup keep_pdf tex_message character, TeX script vector of character, in case of special needs, instead of asking texpreview to build up, you may choose to pass in the contents of the complete LaTeX file directly. It should be a vector of character with each element as a line of raw TeX code. character, name to use in output files, Default: NULL character, output destination. If NULL a temp.dir() will be used and no output will be saved, Default: tex_opts$get( filedir ) logical, controls if overwriting of output stem* files given their existences table margin for pdflatex call, Default: tex_opts$get( margin ) character, defines the type of image the PDF is converted to Default: tex_opts$get( imgformat ) character, one of "viewer", "html", or "tex" determining appropriate return type for the rendering process, Default: tex_opts$get( returntype ) logical, forces a tabular tex object to be constrained on the margins of the document, Default: tex_opts$get( resizebox ) character, vector of usepackage commands, see details for string format character, specifies which latex to pdf engine to use ( pdflatex, xelatex, lualatex ), Default: tex_opts$get( engine ) character, vector of file extensions to clean up after building pdf, Default: tex_opts$get( cleanup ) logical, controls if the rendered pdf file should be kept or deleted, Default is FALSE logical, controls if latex executing messages are displayed in console. Default is FALSE density numeric, controls the density of the image. Default is 150: tex_opts$get( density) print.xtable.opts list, contains arguments to pass to print.table, relevant only if xtable is used as the input, Default: tex_opts$get( print.xtable.opts ) opts.html list, html options, Default: tex_opts$get( opts.html )... passed to system The function assumes the system has pdflatex installed and it is defined in the PATH. The function does not return anything to R. If filedir is specified then two files are written to the directory. An image file of the name stem with the extension specified in imgformat. The default extension is png.the second file is the TeX script used to create the output of the name stem.tex. If you do not wish to view the console output, pass the corresponding arguments to..., e.g., ignore.stdout=true. usrpackage accepts a vector of character strings built by the function buildusepackage, of the form \\usepackage[option1,option2,...]{package_name}, see the TeX wikibook for more information https://en.wikibooks.org/wiki/latex/document_structure# Packages.

tex_opts 5 data('iris') if(interactive()){ #use xtable to create tex output texpreview(obj = xtable::xtable(head(iris,10))) #use knitr kable to create tex output texpreview(knitr::kable(mtcars, "latex")) tex='\\begin{tabular}{llr} \\hline \\multicolumn{2}{c}{item} \\\\ \\cline{1-2} Animal & & Price (\$) \\\\ \\hline Gnat & per gram & 13.65 \\\\ & each & 0.01 \\\\ Gnu & stuffed & 92.50 \\\\ Emu & stuffed & 33.33 \\\\ Armadillo & frozen & 8.99 \\\\ \\hline \\end{tabular}' texpreview(obj = tex,stem = 'eq',imgformat = 'svg') tikz_example <- system.file('examples/tikz/credit-rationing.tex',package = 'texpreview') tikzex=readlines(tikz_example,warn = FALSE) #use tex_lines parameter to pass full document texpreview(tex_lines = tikzex) #use texpreview preamble to build document chunks usetikz=paste(tikzex[14:23],collapse="\n") bodytikz=paste(tikzex[25:90],collapse="\n") texpreview(obj = bodytikz,usrpackages = buildusepackage(pkg = 'tikz',uselibrary = usetikz)) } tex_opts Default and current tex options Options for functions in the texpreview package. When running R code, the object tex_opts (default options) is not modified by chunk headers (local chunk options are merged with default options), whereas tex_opts_current (current options) changes with different chunk headers and it always reflects the options for the current chunk.

6 tex_opts Format Note tex_opts tex_opts_current An object of class list of length 5. Normally we set up the global options once in the first code chunk in a document using tex_opts$set(), so that all latter chunks will use these options. Note the global options set in one chunk will not affect the options in this chunk itself, and that is why we often need to set global options in a separate chunk. Below is a list of default chunk options, retrieved via tex_opts$get(): These options correspond to fields in the direct call to texpreview, which are listed in explained in the help manual. tex_opts_current is read-only in the sense that it does nothing if you call tex_opts_current$set(); you can only query the options via tex_opts_current$get(). tex_opts$get('margin')

Index Topic datasets tex_opts, 5 buildusepackage, 2, 4 gettexpackages, 3 tex_opts, 5 tex_opts_current (tex_opts), 5 texpreview, 3, 6 7