Package 'latexsvg'

Title: What the Package Does (Title Case)
Description: More about what it does (maybe more than one line) Use four spaces when indenting paragraphs within the Description.
Authors: Who wrote it
Maintainer: The package maintainer <[email protected]>
License: What license is it under?
Version: 0.1.0
Built: 2026-07-24 10:48:53 UTC
Source: https://github.com/skranz/latexsvg

Help Index


Takes the code of an svg file that has <text> blocks with latex math E.g. <text>\(x^2\)</text> Renders the latex via MathJax and inlines it into the svg. The function briefly starts a shinyapp since the transformation needs MathJax to be run in the browser. Will work in the RStudio viewer and in Firefox. Does not seem to work in Chrome.

Description

The javascript code that does the actually work is a minimally adapted version of the code by Jason Sachs. See the following references:

Usage

latexsvg(svg = paste0(readLines(file), collapse = "\n"), file = NULL,
  outfile = if (!is.null(file)) paste0(tools::file_path_sans_ext(file),
  "_latex.svg"))

Arguments

svg

the code of svg as text

file

a file name of the svg if no code is given

outfile

if not null the created svg will be written to this file

Details

https://www.embeddedrelated.com/showarticle/599.php https://bitbucket.org/jason_s/svg_mathjax

Value

The code of the generated svg file


A function that converts a graphic in PDF format to an svg file and saves the svg file in the same directory as the pdf file Needs inkscape and the path to it binary

Description

A function that converts a graphic in PDF format to an svg file and saves the svg file in the same directory as the pdf file Needs inkscape and the path to it binary

Usage

pdf2svg(file, inkscape.bin, svg.file = paste0(tools::file_path_sans_ext(file),
  ".svg"))

Arguments

file

the pdf file

inkscape.bin

path and file name of the inkscape binary

svg.file

the output svg file; by default the same name as the pdf file but with extension .svg.