stefano-meschiari / latex2exp

Use LaTeX in R graphics.
Other
188 stars 10 forks source link

output options not consistent between TeX and .parseTeX #28

Closed gowachin closed 2 years ago

gowachin commented 4 years ago

Using Tex, the possible outputs options in doc are c("expression", "text", "ast"). From what I observed, "expression" and "text" return the same result.

While looking at the function .parseTeX, the possible returns are triggered with the following code :

  if (output[1] == "ast") 
    return(root)
  str <- toString(root)
  exp <- tryCatch(parse(text = str), error = function(e) {
    cat("Original string: ", original, "\n")
    cat("Parsed expression: ", str, "\n")
    stop(e)
  })
  if (output[1] == "character") {
    return(str)
  }
  else return(exp)

Does this mean that the TeX return options are c("expression", "character", "ast") and not c("expression", "text", "ast") ? I expect so, because when using TeX(sprintf("$V_l = %.4f$", vl), output = c('expression')) I get a string.

Is it possible to change the documentation and the code ?

stefano-meschiari commented 2 years ago

This should be fixed in 0.9.0. The allowed options are 'expression', 'character', 'ast'.