在常规的bookdown格式中,每个章节都以粗体字开头:
但是这会使章节号和标题变灰,但是章节标题的格式会改为:
第一章
章节标题
我想将“第一章”的颜色更改为深灰色,而不是黑色。我完全不懂LaTeX,但根据其他Stackoverflow问题组合了一些代码来自定义颜色。我创建了一个mystyles.sty
文件,其中包含:
\usepackage{titlesec}
\usepackage{xcolor}
\definecolor{battleshipgrey}{rgb}{0.52, 0.52, 0.51}
\titleformat{\thechapter}
{\color{battleshipgrey}\normalfont\Large\bfseries}
{\color{battleshipgrey}\chapter}{1em}{}
我的YAML头部是:
title: "My Title"
author: "Me"
date: ""
output: pdf_document
bibliography: [bib.bib]
documentclass: book
geometry: left=4cm, right=3cm, top=2.5cm, bottom=2.5cm
link-citations: yes
classoption: openany
biblio-style: apalike
subparagraph: true
我有一个名为_output.yml的文件,其中包含以下代码:
bookdown::pdf_book:
includes:
in_header: mystyles.sty
latex_engine: xelatex
citation_package: natbib
keep_tex: no
mainfont: Bookman
我的 mystyles.sty
文档中有哪些设置不正确?当前,颜色没有被改变。我尝试了以下设置:
\titleformat{\chapter}
{\color{battleshipgrey}\normalfont\Large\bfseries}
{\color{battleshipgrey}\thechapter}{1em}{}
但是这会使章节号和标题变灰,但是章节标题的格式会改为:
1 章节标题
。
\chapternumberfont
,但没有成功。我认为Bookdown没有将章节编号的名称设置为这个特定的名称。我找到了一个解决方法,通过将整个章节设置为灰色,然后将章节标题设置为黑色:\chapterfont{\color{battleshipgrey}} \chaptertitlefont{\color{black}}
- kneijenhuijs