r - 使用 knitr PACKAGE LATEX "titlesec" 从 rstudio 更改 .pdf 文档的章节样式
问题描述
我尝试使用latex titlesec包对文章文档(documentclass:article)的章节(sections)进行样式设置,但没有得到任何结果,我的意思是当我配置文档时没有任何变化。
在 rmarkdown 的 YAML 标头中
header-includes:
## Style Chapter - package "TITLESEC"
- \usepackage[T1]{fontenc}
- \usepackage{titlesec, blindtext, color}
在 YAML 标头之外
<!-- TITLESEC - Estilo CAPÍTULOS -->
\definecolor{gray75}{gray}{0.75}
\newcommand{\hsp}{\hspace{20pt}}
\titleformat{\chapter}[hang]{\Huge\bfseries}{\thechapter\hsp\textcolor{gray75}{|}\hsp}{0pt}{\Huge\bfseries}
\titleformat{\section}[hang]{\Huge\bfseries}{\thechapter\hsp\textcolor{gray75}{|}\hsp}{0pt}{\Huge\bfseries}
在 .tex 文件中章节(section)的代码:
\hypertarget{name-section}{%
\section{Name Section}\label{name-section}}
解决方案
我为你做了一个工作模板。
您可以根据需要进一步调整它。
---
title: "test"
header-includes:
- \usepackage[T1]{fontenc}
- \usepackage{titlesec, blindtext, color}
output:
pdf_document:
toc: true
number_sections: true
documentclass: report
---
\definecolor{gray75}{gray}{0.75}
\newcommand{\hsp}{\hspace{20pt}}
\titleformat{\chapter}[hang]{\Huge\bfseries}{\thechapter\hsp\textcolor{gray75}{|}\hsp}{0pt}{\Huge\bfseries}
\chapter{RMarkdown}
\chapter{Stackoverflow}
推荐阅读
- sql - 如何检查上次运行 PSQL 函数的时间?
- linux - Cron Job 或任何使服务器每天执行 git-pull 的方法
- flask - Celery 容器是否需要拥有所有应用程序代码才能运行应用程序的任务?
- css - wordpress custom-style.css 不应用样式
- python - 无法从烧瓶应用程序插入 MySQL 数据库?
- r - 使用 R Shiny 中的选定输入更改文本和绘图
- reactjs - 如何修复 laravel mix 中的错误“模块解析失败:意外字符”
- javascript - Angular - 如何创建全局函数?
- build - YOCTO how to install 3rd party library(RASPICAM) from github
- locust - 流式 API 的蝗虫