José Carlos
José Carlos

Reputation: 233

Change the style of chapters (sections) of the .pdf document from rstudio with knitr PACKAGE LATEX "titlesec"

I try to style the chapters (sections) of an article document (documentclass: article) using the latex titlesec package, but I don't get any results, I mean that when I configure the document there is no change.

In the YAML header of rmarkdown

header-includes:
## Style Chapter - package "TITLESEC"
  - \usepackage[T1]{fontenc}
  - \usepackage{titlesec, blindtext, color}

Outside the YAML header


<!-- 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}

In the .tex file the code of the chapter (section):


\hypertarget{name-section}{%
\section{Name Section}\label{name-section}}


Upvotes: 0

Views: 813

Answers (1)

manro
manro

Reputation: 3677

I made a working template for you.

You can tune it further as you wish.

---
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}

Upvotes: 1

Related Questions