Anyone suggestions on how to get roboto font in bookdown::pdf_document2?
The code below works fine, when I change the font to Roboto it does not, see also picture. The Roboto and the Comic Sans MS font are in my c:\Windows\Fonts, I use Miktex for pdf-ing. Thanks!
---
header-includes:
- \usepackage{fontspec}
- \setmainfont{Comic Sans MS}
output:
bookdown::pdf_document2:
toc: false
latex_engine: xelatex
---
# Title
This is some text.
This is some more text.
You can do \usepackage{roboto}. See README of the package for further detailed usage. If you knit the document without roboto package, programmes for knitting documents using LaTeX (e.g. R's tinytex or even MikTeX) will automatically install the missing package(s). See the relevant page of R Markdown Cookbook.
To make specific texts san serif
---
header-includes:
- \usepackage{roboto}
# - \usepackage[sfdefault]{roboto} # To make every texts san serif
output:
bookdown::pdf_document2:
toc: false
latex_engine: xelatex
---
# Title
This is some text.
This is some more text.
`\textsf{This is a san serif text.}`{=latex}
To make every texts san serif
---
header-includes:
#- \usepackage{roboto}
- \usepackage[sfdefault]{roboto} # To make every texts san serif
output:
bookdown::pdf_document2:
toc: false
latex_engine: xelatex
---
# Title
This is some text.
This is some more text.
`\textsf{This is a san serif text.}`{=latex}
Related
I'm trying to figure out how I could write my doctoral thesis using R Markdown. Usually, I write articles with Latex. But, I'd like to be able to compile my file both for Word and pdf. Could you please help me understand how I could achieve that? I need to number the \frontmatter in roman numbers and the \mainmatter in arabic numbers.
This is my MWE:
---
title: "A title"
documentclass: book
classoption:
- hidelinks
- twoside
- openright
papersize: a4paper
output:
pdf_document:
includes:
in_header: Mypreamble.tex
latex_engine: xelatex
citation_package: biblatex
toc: yes
toc_depth: 4
number_sections: yes
html_document:
toc: yes
toc_depth: '4'
df_print: paged
word_document:
toc: yes
toc_depth: 4
date: "8 juillet 2022"
bibliography: Lectures.bib
fontsize: 12pt
geometry: left=4cm,right=4cm,top=4cm,bottom=4cm
linestretch: 1.2
toc-title: Plan
links-as-notes: yes
link-citations: yes
header-includes:
- \usepackage{fontspec}
- \setmainfont[Mapping=tex-text]{Arial}
- \usepackage [french]{babel}
- \usepackage[backend=biber,style=apa]{biblatex}
---
Introduction
I did my PhD thesis entirely in R Markdown, outputting to Microsoft Word.
I have a Github repository here if it helps: https://github.com/dannyjnwong/PhD_Thesis
I have also previously blogged about the process here:
https://dannyjnwong.github.io/Writing-a-multi-chapter-document-with-R-Markdown/
I need to knit my Markdown script into a pdf file, but when knitted, the pdf file does not show special Latin characters, such as those used in the International Phonetic Alphabet (IPA).
---
title: "MarkdownIPA"
date: '2022-07-06'
output:
pdf_document:
latex_engine: xelatex
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
`Print IPA`
```{r}
'[aɪ.pʰiː.ɛɪ]'
```
Which rends:
How can I fix this?
You'll need to use a font that supports those glyphs. A (IMHO) rather nice one is Source Sans Pro and the monospace variant Source Code Pro.
To use Source Code Pro, you can add the respective LaTeX code directly:
---
title: "MarkdownIPA"
date: '2022-07-06'
output:
pdf_document:
latex_engine: xelatex
header-includes:
- \usepackage{sourcecodepro}
---
Result:
The sourcecodepro package is likely already installed; otherwise you'd have to install it first.
In my Rmarkdown project, I'm having trouble in correctly exporting ligatures in PDF file.
font-config.tex file -
\usepackage{fontspec}
\setmainfont{Noto Sans}
YAML front-matter in Rmd file -
---
title: "test"
author: "author"
date: "22/02/2021"
output:
pdf_document:
latex_engine: xelatex
includes:
in_header: font-config.tex
---
The following text is in hindi language.
गुरु
Output shown in PDF -
Output expected -
The Nakula font is correctly displayed, but it does not have bold-face type font.
The Noto Sans font I'm using works fine in html output, but have problem with ligature in PDF output.
I tried, the pandoc documentation and other similar questions on stackoverflow and tex.stackexchange, but no luck.
I'm new to TeX, and hopefully it has a very simple solution.
This may work for you, following the information given here:
---
title: "Hindi"
author: "bttomio"
output:
pdf_document:
latex_engine: xelatex
header-includes:
- \usepackage{fontspec}
- \setmainfont{Noto Sans}
- \usepackage{polyglossia}
- \setdefaultlanguage{hindi}
- \setotherlanguage{english}
- \newfontfamily\devanagarifont[Scale=MatchUppercase]{Nakula}
- \newfontfamily\devtransl[Mapping=DevRom]{Times New Roman}
---
The following text is in hindi language.
गुरु
-output
I have a Rmd (see bellow) file and when I execute the file without toc and pandoc I am able to get the title and author, but with them I am not able to see them. How can I get my title and author name to appear with numbered sections and toc?
---
title: "Design"
author: "Jen"
output:
html_document:
toc: true
pandoc_args: [
"--number-sections"
]
---
# plots
You should give rmarkdown full control over the pandoc arguments:
---
title: "Design"
author: "Jen"
output:
html_document:
toc: true
number_sections: true
---
# plots
Source: https://bookdown.org/yihui/rmarkdown/html-document.html#section-numbering
I am using bookdown::pdf_document2 and I would like to create an article with 2 columns. I am using bookdown to be able to do section referencing.
I used pandoc_args: [
"-V", "classoption=twocolumn" but that made it ignore the font and default to computer modern. Is there a way to get 2 columns articles with pdf_document2 ?
I am using the following header:
output:
bookdown::pdf_document2:
fig_crop: no
keep_tex: yes
latex_engine: xelatex
number_sections: yes
toc: yes
toc_depth: 5
fontsize: 12pt
editor_options:
chunk_output_type: console
sansfont: Source Sans Pro
mainfont: Source Sans Pro
mathfont: Calibri
You can set the classoption within the YAML header:
---
output:
bookdown::pdf_document2:
fig_crop: no
keep_tex: yes
latex_engine: xelatex
number_sections: yes
toc: yes
toc_depth: 5
fontsize: 12pt
editor_options:
chunk_output_type: console
sansfont: Liberation Sans
mainfont: Liberation Sans
classoption: twocolumn
---
I changed the font to one that's available on my system.