2016-02-19 70 views
5

Qual è il contrassegno R equivalente a LaTeX \texttt?Qual è il contrassegno R equivalente a LaTeX texttt?

Con questo 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)`. 

ottengo questo pdf:

enter image description here

Mentre mi piacerebbe avere l'output di questo .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

risposta

4

Non esiste un metodo di riduzione del punteggio nativo. Ma quando il formato di uscita è pdf_document, il rmarkdown equivalente di \texttt è \texttt stessa:

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

Rmarkdown utilizza lattice sotto il cofano per compilare in pdf, così comando più grezzo lattice dovrebbe funzionare come previsto.

Lo stesso vale per l'output html:

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