I can't change a bookdown pdf output font

I am trying to use bookdown package to make reports for my office, which is an office of a public entity of the peruvian goverment (we have a document format that I must use). I make something that works when I use it for a single .Rmd file (I mean, without the bookdown package), but I have troubles to make it work with the bookdown files. The main problems are: (i) The font, because I can't make it use the Helvet or Arial font as I do with the single .Rmd file; and (ii) The table of contents, that I want to disappear but I don´t know how.

Here is the example of the output with the single .Rmd file (the one that works):

---
title-meta: "Reporte interno de Sefa"
author-meta: "Sefa"
date-meta: '\today'
lang: es
documentclass: article
classoption: oneside
keywords: "informe, r studio, r markdown"
geometry:
- top=2cm
- left=2.5cm
- right=2.5cm
- bottom=3.5cm
papersize: a4
fontsize: 11pt
header-includes:
- \usepackage{floatrow}
- \floatplacement{figure}{H}
- \floatplacement{table}{H}
- \floatsetup[figure]{capposition=top}
- \floatsetup[table]{capposition=top}
- \addtolength{\skip\footins}{1pc plus 2pt}
- \usepackage{titlesec}
- \titleformat*{\section}{\filright \normalsize \bfseries}
- \titleformat*{\subsection}{\normalsize\bfseries}
- \titleformat*{\subsubsection}{\normalsize\bfseries}
- \renewcommand{\thesection}{\Roman{section}}
- \renewcommand{\thesubsection}{\Alph{subsection}}
- \usepackage{helvet}
- \renewcommand{\familydefault}{\sfdefault}
- \usepackage{colortbl}
- \usepackage{array}
- \usepackage{graphicx}
- \usepackage{hhline,colortbl}
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \setlength{\headheight}{67pt}
- \fancyhf{}
- \renewcommand{\headrulewidth}{0pt}
- \fancyhead[C]{\setlength{\arrayrulewidth}{0.35mm} \arrayrulecolor{white} \begin{tabular} { | >{\arraybackslash}m{1cm} | >{\arraybackslash}m{1cm} | >{\arraybackslash}m{2cm} | >{\arraybackslash}m{3.75cm} | >{\arraybackslash}m{6cm} |} \includegraphics[width=1cm]{peru} & \cellcolor{red} \textcolor{white}{PERÚ} & \cellcolor[gray]{0.2} \scriptsize \textcolor{white}{Ministerio del Ambiente} & \cellcolor[gray]{0.5} \scriptsize \textcolor{white}{Organismo de Evaluación y Fiscalización Ambiental} &  \cellcolor[gray]{0.5} \scriptsize \textcolor{white}{Subdirección de Seguimiento de Entidades de Fiscalización Ambiental} \\ \end{tabular}\\ \vspace{3mm}{\scriptsize "Decenio de la igualdad de oportunidades para mujeres y hombres"}\\ {\scriptsize "Año de la universalización de la salud"}}
- \fancyfoot[C]{\thepage}
mainfont: helvet
output: 
  pdf_document:
    fig_caption: true
    number_sections: true
    toc: no
---
\rightline{\footnotesize \textbf{Sin registro en el Siged}}
\vspace{1mm}
\centerline{\textbf{INFORME INTERNO}}
\vspace{3mm}
\begin{tabular}
{ p{1.65cm}  p{0.2cm}  p{12.85cm} }
\textbf{A} & : & \textbf{MY BOSS NAME}\\
& & His jobs tittle... \\
& & \\
\textbf{DE} & : & \textbf{MY NAME}\\
& & My jobs tittle...\\
& & \\
\textbf{ASUNTO} & : & The subject...\\
& & \\
\textbf{FECHA} & : & Lima (which is our city), the date... \\
& & \\
\hline
\end{tabular}
\vspace{1mm}
\normalsize

And here are the index.Rmd file and the preamble.txt file with the bookdown package (the one which is not working):

Index.Rmd:

--- 
metatitle: "A Minimal Book Example"
metaauthor: "Yihui Xie"
metadate: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: article
geometry:
- top=2cm
- left=2.5cm
- right=2.5cm
- bottom=3.5cm
papersize: a4
fontsize: 11pt
mainfont: helvet
bibliography: [book.bib, packages.bib]
biblio-style: apalike
link-citations: yes
description: "..."
---
\rightline{\footnotesize \textbf{Sin registro en el Siged}}
\vspace{1mm}
\centerline{\textbf{INFORME INTERNO}}
\vspace{3mm}
\begin{tabular}
{ p{1.65cm}  p{0.2cm}  p{12.85cm} }
\textbf{A} & : & \textbf{MY BOSS NAME}\\
& & His jobs tittle... \\
& & \\
\textbf{DE} & : & \textbf{MY NAME}\\
& & My jobs tittle...\\
& & \\
\textbf{ASUNTO} & : & The subject...\\
& & \\
\textbf{FECHA} & : & Lima (which is our city), the date... \\
& & \\
\hline
\end{tabular}
\vspace{1mm}
\normalsize

preambule.text:

\usepackage{booktab}
\usepackage{floatrow}
\floatplacement{figure}{H}
\floatplacement{table}{H}
\floatsetup[figure]{capposition=top}
\floatsetup[table]{capposition=top}
\addtolength{\skip\footins}{1pc plus 2pt}
\usepackage{titlesec}
\titleformat*{\section}{\filright \normalsize \bfseries}
\titleformat*{\subsection}{\normalsize\bfseries}
\titleformat*{\subsubsection}{\normalsize\bfseries}
\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\thesubsection}{\Alph{subsection}}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{colortbl}
\usepackage{array}
\usepackage{graphicx}
\usepackage{hhline,colortbl}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength{\headheight}{67pt}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[C]{\setlength{\arrayrulewidth}{0.35mm} \arrayrulecolor{white} \begin{tabular} { | >{\arraybackslash}m{1cm} | >{\arraybackslash}m{1cm} | >{\arraybackslash}m{2cm} | >{\arraybackslash}m{3.75cm} | >{\arraybackslash}m{6cm} |} \includegraphics[width=1cm]{peru} & \cellcolor{red} \textcolor{white}{PERÚ} & \cellcolor[gray]{0.2} \scriptsize \textcolor{white}{Ministerio del Ambiente} & \cellcolor[gray]{0.5} \scriptsize \textcolor{white}{Organismo de Evaluación y Fiscalización Ambiental} &  \cellcolor[gray]{0.5} \scriptsize \textcolor{white}{Subdirección de Seguimiento de Entidades de Fiscalización Ambiental} \\ \end{tabular}\\ \vspace{3mm}{\scriptsize "Decenio de la igualdad de oportunidades para mujeres y hombres"}\\ {\scriptsize "Año de la universalización de la salud"}}
\fancyfoot[C]{\thepage}

Please tell me if somebody has an idea.

2 Likes

I solve the table of contents problem. The solution was to change the output.yml file with:

bookdown::pdf_book:
  toc: false

But I still have problems with the font :pensive:

I can say from experience that troubleshooting bookdown with font issues can be a hassle. I'd suggest you put together a reprex as an r project on github, and link to that. If you get no joy here, you could then try stackoverflow.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.