R/tex_addin.R

Defines functions tex_addin

#' @importFrom rstudioapi getActiveDocumentContext
tex_addin <- function() {
  # Get the document context.
  context <- rstudioapi::getActiveDocumentContext()
  
  # Set the default data to use based on the selection.
  obj <- context$selection[[1]]$text
  
  if (nchar(obj) == 0) {
    stop('Please highlight a tex before selecting this addin.')
  }
  
  if(grepl('xtable',obj)){
    eval(parse(text=paste0('obj=',obj)))
  }else{
    obj=gsub('\\\\\\\\','\\\\',obj)
  } 
  
  tex_preview(obj = obj)
}

Try the texPreview package in your browser

Any scripts or data that you put into this service are public.

texPreview documentation built on May 29, 2024, 5:45 a.m.