如何使用乳胶在 bookdown 中格式化目录?
How do I format a TOC in bookdown using latex?
我正在使用带有乳胶样式的 bookdown 制作包含 headers、页脚和部分格式的报告。当我编写报告时,除 TOC 外,所有页面的格式都正确。
MWE 在下方。没有 headers 并且默认的章节标题格式未应用于内容页面。
index.Rmd
---
title: "A Quick Test"
author: "Jack Jill"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: article
description: "This is a minimal example of a report."
papersize: a4
output:
bookdown::pdf_document2:
includes:
in_header: in_header.tex
before_body: before_body.tex
toc: true
geometry: top=20mm,bottom=60mm,footnotesep=10mm,left=24mm,right=30mm
---
\newpage
# **HEADING 1**
## **Subheading**
Here is some text for the document.
# **HEADING 2**
Here is some text for the document.
# **HEADING 3**
Here is some text for the document.
in_header.tex
%Essential packages
\usepackage{graphicx, color}
\usepackage{multirow}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{etoolbox}
\usepackage{tocloft}
\definecolor{airforceblue}{rgb}{0.36, 0.54, 0.66}
\definecolor{aliceblue}{rgb}{0.94, 0.97, 1.0}
\definecolor{amber}{rgb}{1.0, 0.75, 0.0}
\definecolor{amaranth}{rgb}{0.9, 0.17, 0.31}
\definecolor{amber}{rgb}{1.0, 0.75, 0.0}
\definecolor{black}{rgb}{0, 0, 0}
% This changes all section headings
\titleformat*{\section}{\bfseries\Large\itshape}
\titleformat*{\section}{\color{airforceblue}}
% Turn off default title page so I can make my own
\let\oldmaketitle\maketitle
\AtBeginDocument{\let\maketitle\relax}
before_body.tex
\pagestyle{fancy}
\fancyhead{}
\fancyhf{}
% Page layout
\parindent 0pt
\parskip 0pt
% Make custom page numbers
\cfoot{Page \thepage \hspace{1pt} of \pageref{LastPage}}
% Make a pretty header for every page
\fancyhead[L]{\includegraphics[width=3.5cm]{logo.png}}
\fancyhead[R]{\raisebox{1.6cm}{\color{amaranth}www.website.com.au}}
% Make the title page here
\setlength\headheight{68pt}
\vspace*{2.5cm}
\fontsize{36pt}{42pt}\selectfont\bfseries\color{airforceblue}
MY REPORT TITLE
\vspace*{0.5cm}
\color{airforceblue}
{\bfseries\huge{ SUBTITLE } }
\vspace*{1.0cm}
\colorbox{amber}{\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\bfseries\huge\strut\textcolor{aliceblue}{ AUTHOR NAME } }}
% replace default title page with my new one
\let\maketitle\oldmaketitle
% end page
\clearpage
% Set default fonts for doc
\fontsize{10}{12}\selectfont
\fontfamily{qcr}\selectfont
\setlength{\headheight}{98pt}
\color{black}
% Manually adding TOC does not add header either
% \tableofcontents
% \addcontentsline{toc}{section}{\contentsname}
目录页面使用 plain
页面样式。如果您的 fancyhdr
包版本是合理的新版本,您可以使用简单的命令
将普通页面样式更改为与您的 fancy
页面样式相同
\fancypagestyle{plain}[fancy]{}
---
title: "A Quick Test"
author: "Jack Jill"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: article
description: "This is a minimal example of a report."
papersize: a4
output:
bookdown::pdf_document2:
toc: true
toc_depth: 2
keep_tex: true
includes:
in_header: in_header.tex
before_body: before_body.tex
header-includes: \fancypagestyle{plain}[fancy]{}
geometry: top=20mm,bottom=60mm,footnotesep=10mm,left=24mm,right=30mm
---
\newpage
# **HEADING 1**
## **Subheading**
Here is some text for the document.
# **HEADING 2**
Here is some text for the document.
# **HEADING 3**
Here is some text for the document.
我正在使用带有乳胶样式的 bookdown 制作包含 headers、页脚和部分格式的报告。当我编写报告时,除 TOC 外,所有页面的格式都正确。
MWE 在下方。没有 headers 并且默认的章节标题格式未应用于内容页面。
index.Rmd
---
title: "A Quick Test"
author: "Jack Jill"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: article
description: "This is a minimal example of a report."
papersize: a4
output:
bookdown::pdf_document2:
includes:
in_header: in_header.tex
before_body: before_body.tex
toc: true
geometry: top=20mm,bottom=60mm,footnotesep=10mm,left=24mm,right=30mm
---
\newpage
# **HEADING 1**
## **Subheading**
Here is some text for the document.
# **HEADING 2**
Here is some text for the document.
# **HEADING 3**
Here is some text for the document.
in_header.tex
%Essential packages
\usepackage{graphicx, color}
\usepackage{multirow}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{etoolbox}
\usepackage{tocloft}
\definecolor{airforceblue}{rgb}{0.36, 0.54, 0.66}
\definecolor{aliceblue}{rgb}{0.94, 0.97, 1.0}
\definecolor{amber}{rgb}{1.0, 0.75, 0.0}
\definecolor{amaranth}{rgb}{0.9, 0.17, 0.31}
\definecolor{amber}{rgb}{1.0, 0.75, 0.0}
\definecolor{black}{rgb}{0, 0, 0}
% This changes all section headings
\titleformat*{\section}{\bfseries\Large\itshape}
\titleformat*{\section}{\color{airforceblue}}
% Turn off default title page so I can make my own
\let\oldmaketitle\maketitle
\AtBeginDocument{\let\maketitle\relax}
before_body.tex
\pagestyle{fancy}
\fancyhead{}
\fancyhf{}
% Page layout
\parindent 0pt
\parskip 0pt
% Make custom page numbers
\cfoot{Page \thepage \hspace{1pt} of \pageref{LastPage}}
% Make a pretty header for every page
\fancyhead[L]{\includegraphics[width=3.5cm]{logo.png}}
\fancyhead[R]{\raisebox{1.6cm}{\color{amaranth}www.website.com.au}}
% Make the title page here
\setlength\headheight{68pt}
\vspace*{2.5cm}
\fontsize{36pt}{42pt}\selectfont\bfseries\color{airforceblue}
MY REPORT TITLE
\vspace*{0.5cm}
\color{airforceblue}
{\bfseries\huge{ SUBTITLE } }
\vspace*{1.0cm}
\colorbox{amber}{\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\bfseries\huge\strut\textcolor{aliceblue}{ AUTHOR NAME } }}
% replace default title page with my new one
\let\maketitle\oldmaketitle
% end page
\clearpage
% Set default fonts for doc
\fontsize{10}{12}\selectfont
\fontfamily{qcr}\selectfont
\setlength{\headheight}{98pt}
\color{black}
% Manually adding TOC does not add header either
% \tableofcontents
% \addcontentsline{toc}{section}{\contentsname}
目录页面使用 plain
页面样式。如果您的 fancyhdr
包版本是合理的新版本,您可以使用简单的命令
fancy
页面样式相同
\fancypagestyle{plain}[fancy]{}
---
title: "A Quick Test"
author: "Jack Jill"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: article
description: "This is a minimal example of a report."
papersize: a4
output:
bookdown::pdf_document2:
toc: true
toc_depth: 2
keep_tex: true
includes:
in_header: in_header.tex
before_body: before_body.tex
header-includes: \fancypagestyle{plain}[fancy]{}
geometry: top=20mm,bottom=60mm,footnotesep=10mm,left=24mm,right=30mm
---
\newpage
# **HEADING 1**
## **Subheading**
Here is some text for the document.
# **HEADING 2**
Here is some text for the document.
# **HEADING 3**
Here is some text for the document.