如何在Rmarkdown中为所选文本着色

时间:2019-04-01 15:13:46

标签: r r-markdown

我只想给文档中选定的文本涂上颜色。但是,即使我指定仅在括号{}中应用颜色(尤其是蓝色),我的文档的其余部分都变成了蓝色。

我尝试使用\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

1 个答案:

答案 0 :(得分:0)

如果在紧接“问题2”之前的\color{black}之后添加\quad,那应该可以达到预期的效果。


\color{blue}__Answer:__

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

\quad

\color{black}

Question 2: