texPreview (version 2.1.0)

build_usepackage: Build usepackage command for TeX document

Description

input TeX package name and optional package functions to create usepackage call

Usage

build_usepackage(pkg, options = NULL, uselibrary = NULL, chk.inst = FALSE)

Value

character

Arguments

pkg

character, name of TeX package

options

character, name(s) of options to use in the package

uselibrary

character, part of document preamble to specify a uselibrary call related to package

chk.inst

logical, invokes a check to see if pkg is currently installed on system (default FALSE)

Details

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.

Examples

Run this code
build_usepackage(pkg = 'xcolor')
build_usepackage(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(build_usepackage,
pkg =        list('times','geometry','tikz'),
options=     list(NULL   ,geom.opts ,NULL),
uselibrary = list(NULL   ,NULL      ,use.opts)
))

Run the code above in your browser using DataLab