【问题标题】:How to just color a chosen text in Rmarkdown如何在 Rmarkdown 中为选定的文本着色
【发布时间】:2019-04-01 15:13:45
【问题描述】:

我只想为我的文档中选定的文本着色。然而,即使当我指定颜色(特别是蓝色)仅应用于括号 {} 时,我的文档的其余部分都变成了蓝色。

我尝试使用\par 甚至\quad。它没有用。

当我尝试\textcolor{blue}{my text} 时,它只适用于那个特定的实例。

但是,当我尝试时


    \color{blue}__Answer:__

    1+1

    $$
    x_1 + x_2 = 2x_3^{2}
    $$

    \quad

该文本块是蓝色的,文档的其余部分也是蓝色的,这不是我想要的。

以下是我的 Rmarkdown 文档中的内容

Question 1

Let $x_1$ and $x_2$ be two random variables with covariance matrix:
$$
\boldsymbol{\Sigma} =
\begin{pmatrix}
    7        & \sqrt{5} \\
    \sqrt{5} & 3
\end{pmatrix}
$$Find the principal components (eigenvalues and eigenvectors) and compute the percentage of the total variance explained by each component.

\color{blue}__Answer:__

$$
x_1 + x_2 = 2x_3^{2}
$$

\quad

Question 2: 

work through their Eating in the UK example about food in the United Kingdom work through their Eating in the UK example about food in the United Kingdom work through their Eating in the UK example about food in the United Kingdom

【问题讨论】:

    标签: r r-markdown


    【解决方案1】:

    如果您在紧接“问题 2:”之前的 \quad 之后添加 \color{black},那应该会给您想要的效果。

    
    \color{blue}__Answer:__
    
    $$
    x_1 + x_2 = 2x_3^{2}
    $$
    
    \quad
    
    \color{black}
    
    Question 2: 
    

    【讨论】:

    • 干杯!这有点笨拙,因为您每次都必须重新声明 \color{blue} / \color{black}。您可以创建一个自定义命令(如“answer”)并使用 \begin{answer}\end{answer} 调用它,但现在应该这样做。
    猜你喜欢
    • 2019-08-12
    • 1970-01-01
    • 2017-07-07
    • 2021-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-17
    相关资源
    最近更新 更多