Pregunta

I'm trying to italicise a scientific name when converting a .Rnw file to a .tex file using knitr. I'm getting an error when running knit. This is my code contained within my .Rnw file (needs taxize and stringr libraries to run):

Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum \Sexpr{str_c("Collared Flycatchers (\\textit{", comm2sci(commnames='Collared Flycatcher', db="itis")[[1]], "})")[1]}

The output in the .tex file should be:

Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Collared Flycatchers (\textit{Ficedula semitorquata})

How can I get this output in the .tex file?

¿Fue útil?

Solución

This works for me

\documentclass{article}
\begin{document}
<<message=FALSE>>=
library("taxize")
@
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum \textit{\Sexpr{comm2sci(commnames='Collared Flycatcher', db="itis")[[1]][2]}}
\end{document}

Does this give you what you want? Looks right in the output pdf for me.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top