RMarkdown - Change Inline Code Color

前端 未结 2 931
一向
一向 2021-01-05 20:53

I am using inline code in RMarkdown and I would like all the text that is a result of inline code to be a different color in the document. In this example, I would like heat

2条回答
  •  借酒劲吻你
    2021-01-05 21:32

    Or you can use text_spec in kableExtra. It literarily does the same thing but just a tiny bit more literal. See more here

    ---
    title: ''
    output: html_document
    ---
    
    ```{r setup, include=FALSE}
    knitr::opts_chunk$set(echo = TRUE)
    library(kableExtra)
    ```
    
    ## R Markdown
    
    This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see .
    
    This is inline code: `r text_spec(colnames(mtcars)[1], color = "red")`.
    
    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. You can embed an R code chunk like this:
    
    ```{r cars}
    summary(cars)
    ```
    
    ## Including Plots
    
    You can also embed plots, for example:
    
    ### This is more inline code `r text_spec(colnames(mtcars)[2], color = "red")`.
    
    Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
    

提交回复
热议问题