目录的rmarkDown表更改字体颜色
我正在尝试在混合乳胶R标记文档上为我的目录使用自定义颜色。我将目录设置为Webblue颜色,并希望我的部分和小节是不同的字体颜色,但是,当我将颜色更改为“ niceblue”时,内容表中的条目也会更改为“ niceblue”。问题:如何在不更改目录上的颜色的情况下更改文档部分的颜色?感谢您的帮助。请参阅下面使用的代码:
---
title: "Age Assignment"
author: "joe"
date: "`r Sys.Date()`"
output:
pdf_document: default
header-includes:
- \geometry{top=1.3cm, bottom=1.0cm, left=1.8cm, right=1.8cm,footskip=.5cm}
- \usepackage{hyperref}
- \hypersetup{colorlinks = true, linkcolor = webblue, urlcolor = red}
- \usepackage{pdflscape}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
- \usepackage{longtable,ctable}
- \usepackage{url}
- \usepackage{relsize}
- \usepackage[compact]{titlesec}%use 'compact' to shrink the whitespace on sections,sub,subsub
- \hypersetup{pdfstartview={XYZ null null 0.75}}%0.75 prints pdf at 75% zoom level
- \usepackage{setspace}
- \newcommand{\subsubsubsection}[1]{\paragraph{#1}\mbox{}\par\vspace{1mm}} %to add a subsubsubsection
- \setcounter{secnumdepth}{4} %to add a subsubsubsection
- \setcounter{tocdepth}{4} %to add a subsubsubsection
- \titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}%Sections
- \titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}%subsections
- \titlespacing\subsubsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}%subsub
- \definecolor{webblue}{rgb}{0, 0, 0.5} % less intense blue
- \definecolor{bole}{rgb}{0.47, 0.27, 0.23}
- \definecolor{brickred}{rgb}{0.8, 0.25, 0.33}
- \definecolor{niceblue}{rgb}{0.0, 0.53, 0.74}
subtitle: Assessment of populations
number_sections: yes
toc: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(warning = FALSE, message = FALSE,comment="")
```
\color{bole}The purpose of this document is to......\
\color{black}
# Beginning of document
## This is a test
## And this is another test...
## \color{niceblue}Introduction
\color{black}
The Central Valley blah blah\par
### \color{niceblue} Methods
\color{black}
And this is what happened......
I am trying to use custom colors for my table of contents on a mixed latex R markdown document. I set the table of contents to be webblue color and want my sections and subsections to be a different font color, however, when I change the color to 'niceblue', the entry in the table of contents also change to 'niceblue'. Question: How can I change the colors of my documents sections without altering the color on table of contents? Thanks for any help. See code that I am using below:
---
title: "Age Assignment"
author: "joe"
date: "`r Sys.Date()`"
output:
pdf_document: default
header-includes:
- \geometry{top=1.3cm, bottom=1.0cm, left=1.8cm, right=1.8cm,footskip=.5cm}
- \usepackage{hyperref}
- \hypersetup{colorlinks = true, linkcolor = webblue, urlcolor = red}
- \usepackage{pdflscape}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
- \usepackage{longtable,ctable}
- \usepackage{url}
- \usepackage{relsize}
- \usepackage[compact]{titlesec}%use 'compact' to shrink the whitespace on sections,sub,subsub
- \hypersetup{pdfstartview={XYZ null null 0.75}}%0.75 prints pdf at 75% zoom level
- \usepackage{setspace}
- \newcommand{\subsubsubsection}[1]{\paragraph{#1}\mbox{}\par\vspace{1mm}} %to add a subsubsubsection
- \setcounter{secnumdepth}{4} %to add a subsubsubsection
- \setcounter{tocdepth}{4} %to add a subsubsubsection
- \titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}%Sections
- \titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}%subsections
- \titlespacing\subsubsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}%subsub
- \definecolor{webblue}{rgb}{0, 0, 0.5} % less intense blue
- \definecolor{bole}{rgb}{0.47, 0.27, 0.23}
- \definecolor{brickred}{rgb}{0.8, 0.25, 0.33}
- \definecolor{niceblue}{rgb}{0.0, 0.53, 0.74}
subtitle: Assessment of populations
number_sections: yes
toc: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(warning = FALSE, message = FALSE,comment="")
```
\color{bole}The purpose of this document is to......\
\color{black}
# Beginning of document
## This is a test
## And this is another test...
## \color{niceblue}Introduction
\color{black}
The Central Valley blah blah\par
### \color{niceblue} Methods
\color{black}
And this is what happened......
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用真实的乳胶分段命令,则可以指定标题,因为它应该在文本中出现以及TOC的标题:
If you use real latex sectioning commands, you can specify both the title as it should appear in text as well as the title for the toc: