相当于LaTeX \ texttt的R降价是什么?

时间:2016-02-19 22:07:05

标签: r latex markdown

与LaTeX \texttt相当的R降价是什么?

有了这个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)`.

我得到这个pdf:

enter image description here

虽然我想从此.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

1 个答案:

答案 0 :(得分:10)

这样做没有本地降价方式。但是当输出格式为pdf_document时,等同于\texttt的rmarkdown本身就是\texttt

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

Rmarkdown在引擎盖下使用乳胶编译为pdf,因此大多数原始乳胶命令应该按预期工作。

html输出也是如此:

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