What is the R marking equivalent to LaTeX \ texttt?

What is the R marking equivalent to LaTeX \texttt ?

With this MWE:

 --- title: "A test" author: "Alessandro" date: "February 19, 2016" output: pdf_document --- ```{r, echo=FALSE} d<-data.frame(product_name=c('d','a','b','c')) # what to write here to get a typewriter font? ``` Product names are: `r sort(d$product_name)`. 

I get this pdf:

enter image description here

Although I would like to get the result from this .tex file

 \documentclass[a4paper]{article} \usepackage[english]{babel} \usepackage[utf8x]{inputenc} \usepackage{amsmath} \usepackage{graphicx} \usepackage[colorinlistoftodos]{todonotes} \title{A test} \author{Alessandro} \begin{document} \maketitle Product names are: \texttt{a, b, c, d}. \end{document} 

enter image description here

+5
source share
1 answer

There is no way to markdown. But when the output format is pdf_document , the equivalent is rmarkdown \texttt itself \texttt :

 Product names are: \texttt{`r sort(d$product_name)`}. 

Rmarkdown uses latex under the hood to compile to pdf, so most raw latex commands should work as expected.

The same is true for html output:

 Product names are: <tt>`r sort(d$product_name)`</tt>. 
+5
source

Source: https://habr.com/ru/post/1243433/


All Articles