latex_expression: Converts a LaTeX String to Expression

View source: R/geom-magic-text.R

latex_expressionR Documentation

Converts a LaTeX String to Expression

Description

Helper function to convert a LaTeX string to expression.

Usage

latex_expression(
  x,
  sup = NULL,
  sub = NULL,
  space = "\\ ",
  user_defined = list(),
  env = parent.frame(),
  mode = "formula",
  output = "character",
  ...
)

parse_func(..., output = "character")

Arguments

x

a character vector.

sup

one-length character, indicates that characters after this is superscript.

sub

one-length character, indicates that characters after this is subscript.

space

if 'mode = "formula"', will replace space in x with it.

user_defined

user-defined command, see ?latex2exp::TeX for details.

env

environment to evaluate each expression in.

mode

'inline' means string is normal text with some formula, and 'formula' means all string is formula.

output

the type of returned object, should be expression or character.

...

other parameters passing to latex2exp::TeX().

Author(s)

Hou Yun

Examples

name <- c("A_2", "B^3", "C_2", "D^{123 + x}")
name <- latex_expression(name)

Hy4m/linkET documentation built on June 30, 2023, 7:39 p.m.