I am implementing a function print_name in the package taxlist.
For example, I can format a name for markdown:
library(taxlist)
data(Easplist)
print_name(Easplist, 206, style="markdown")
The output in the console is then:
[1] "*Cyperus papyrus* L."
I can use this command for example to mention a species in the content of a markdown document by `r I(print_name(Easplist, 206, style="markdown"))`, where the scientific name appears as italics and the author name does not.
I would like to implement an option (i.e. style="latex") retrieving the string formatted for LaTeX, which can be inserted through something like \Sexpr{print_name(Easplist, 206, style="latex")} (this example is only an hypothetical one).
The output should be then \textit{Cyperus papyrus} L. but all my attempts failed because backslash is a scape in R strings.
Is there a way to achieve properly this task?
Note: The function is at the moment not implemented in the CRAN version of the package, thus to reproduce the example use the last version from GitHub:
devtools::install_github("kamapu/taxlist")
