Posts

Showing posts with the label sweave

Formatted scientific names from R to LaTeX (using Sweave or knitr)

Image
Formatted scientific names from R to LaTeX (using Sweave or knitr) I am implementing a function print_name in the package taxlist. For example, I can format a name for markdown: print_name 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. `r I(print_name(Easplist, 206, style="markdown"))` 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 backslas...