Reputation: 18603
What is the R markdown 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:
While I would like to get the output 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}
Upvotes: 12
Views: 13215
Reputation: 19867
There is no native markdown way of doing this. But when the output format is pdf_document
, the rmarkdown equivalent of \texttt
is \texttt
itself:
Product names are: \texttt{`r sort(d$product_name)`}.
Rmarkdown uses latex under the hood to compile to pdf, so most raw latex command should work as expected.
The same is true for html output :
Product names are: <tt>`r sort(d$product_name)`</tt>.
Upvotes: 15