Hi everyone! I've been using Latex for years now and used it for my PHD, but now I've changed my workflow, I'd like to use R Markdown in every file I work on, especially research articles. To this purpose, I've built a YAML preamble and insert some Latex markups in order to output a documentclass book, but I have some complications:
-
I use fontspec and a specific font and when I compile my file, dashes are not displayed between pages numbers while it displays correctly with the standard font. Why? And how to fix that?
-
The TOC displays wrong numbers in the frontmatter as you can see on the picture:
-
In the backmatter, the header display the previous chapter, not the current one. Why? and how to fix that?
Thanks for your help.
Those are my MWE and my preamble.tex:
---
title: A title
date:
documentclass: book
fontsize: 12pt
geometry: left=6cm,right=6cm,top=7cm,bottom=7cm
linestretch: 1.1
toc-title: Table
links-as-notes: true
link-citations: yes
bibliography: "r-references.bib"
csl: "apa7-fr-couture.csl"
header-includes:
- \usepackage[french]{babel}
- \usepackage{hyperref}
- \usepackage{fontspec}
- \setmainfont[Numbers=OldStyle,Mapping=tex-text]{Janson Text LT Std}
output:
pdf_document:
includes:
in_header: preamble.tex
latex_engine: xelatex
toc: yes
toc_depth: 1
number_sections: yes
html_document:
toc: yes
toc_depth: '5'
df_print: paged
word_document:
toc: yes
toc_depth: 5
---
\frontmatter
# Synopsis
\mainmatter
# A chapter
\backmatter
# A chapter
# References
My preamble.tex :
\frenchspacing
\usepackage{fancyhdr}
\pagestyle{fancy}
% We don’t want chapter and section numbers
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\headrulewidth}{0pt}
\fancyhf{} % sets both header and footer to nothing
\fancyfoot{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[CE]{\textit{A title}} % even pages: chapter title
\fancyhead[CO]{\textit\leftmark} % odd pages: book title
\usepackage{titlesec}
\usepackage{titling}
\titleformat*{\section}{\normalsize\itshape}
\titleformat*{\subsection}{\normalsize\itshape}
\titleformat*{\subsubsection}{\normalsize\itshape}
\titleformat{\chapter}[display]%
{\centering\Large\bfseries}% format of chapter
{\large\normalfont\MakeUppercase{\chaptertitlename}\enskip\thechapter}% format of the label
{.5\baselineskip}{} % space between the two
\titlespacing*{\chapter}{0pt}{25pt}{35pt} % spaces around \chapter{}, {left}{before}{after}
%\titleformat{\chapter}[display]
%{\normalfont\bfseries}{}{0pt}{\Huge}
\setlength\parindent{15pt}\setlength{\parskip}{0.0pt plus 1.0pt}