【发布时间】:2021-06-17 11:54:34
【问题描述】:
如何在使用 rmarkdown 创建 PDF 报告时为文本的特定部分添加背景颜色。如下所示
我尝试过这样的事情,但它在乳胶中工作,但在 rmarkdown 中没有
\titleformat{\section}{\sffamily\Large\bfseries\rlap{\color{DarkGreen!90}\rule[-0.5ex]{\linewidth}{3ex}\vspace{-3ex}}\sffamily\Large\color{white}}{\thesection}{1em}{}
---
title: "Untitled"
output: pdf_document
header-includes:
- \usepackage{amsfonts,amssymb,amsmath}
- \usepackage[table, svgnames]{xcolor}
- \usepackage{titlesec}
- \usepackage{sectsty}
- \usepackage{xcolor, soul}
- \sectionfont{\color{red}}
- \subsectionfont{\color{green}}
- \subsubsectionfont{\color{blue}}
- \titleformat{\section}{\sffamily\Large\bfseries\rlap{\color{DarkGreen!90}\rule[-0.5ex]{\linewidth}{3ex}\vspace{-3ex}}\sffamily\Large\color{white}}{\thesection}{1em}{}
---
\section{Highlights}
# Section
【问题讨论】:
-
你能创建一个minimal reproducible example 来显示你使用的是哪个文档类等吗?
-
您可以将降价代码发布在代码块中而不是图像中吗?
-
可能markdown会自动加载带有不同选项的xcolor包,从而导致报错
标签: r latex r-markdown pdflatex