由于不同的日志要求,我需要频繁地将Rmarkdown中的某些文本样式从一种更改为另一种。例如,下面是一个示例Rmarkdown文档。
---
title: "Changing format of Rmarkdown"
author: "Paul Hargarten"
date: "5/9/2019"
output: html_document
---
```{r setup, include=FALSE}knitr::opts_chunk$set(echo =真)
## R Markdown
This is an $\mathcal{R}$ Markdown document. Markdown is a simple formatting syntax for authoring **HTML**, **PDF**, and **MS Word* documents. For more details on using $\mathcal{R}$ Markdown see <http://rmarkdown.rstudio.com>. $\matcal{R}$ is based on $\mathcal{S}$.
When you click the `Knit` button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. Calculate a `summary` as follows:
```{r cars}摘要(汽车)
## Including Plots
You can also embed plots, for example: `r plot(pressure)`.在不搜索确切短语的情况下,假设我想要查找并替换以下项目:
除以r开头的项目外,将以粗体显示的项目更改为斜体,将看起来像$\mathcal{ ... }$的项目更改为特殊字体`...`,将以r开头的项目更改为`r ... ` => $`r ... `$的美元符号。
是否可以使用regex在Rmarkdown中进行这些格式化样式的更改?谢谢!
发布于 2019-05-10 20:14:52
如果您完全使用LaTeX,则可以根据该标记的用法定义自己的宏。例如,
\newcommand{\booktitle}[1]{\textbf #1}作为\booktitle{The Book}用于书名。
在R Markdown中可以做到这一点,但您不能使用**标记书名。你可以这样做(你可以在R Markdown中嵌入LaTeX ),但是它很丑陋。例如,
---
title: Using LaTeX
output: pdf_document
---
```{r setup, include=FALSE}knitr::opts_chunk$set(echo =真)
\newcommand{\booktitle}[1]{\textbf{#1}}
This is \booktitle{The Book}.一旦你这样做了,你最好切换到类似*.Rnw的格式,或者一直切换到LaTeX。
https://stackoverflow.com/questions/56068056
复制相似问题