hyphen in RMarkdown - r

Hello I'm quite new to using Rmarkdown and using Latex in genral.
I would like to use a hyphen with in a formula in a Rmarkdown html reprot.
This is my code:
---
pagetitle: "Home"
author: "R lumpe"
date: "`r format(Sys.Date(),'%d.%m.%Y')`"
output:
html_document:
df_print: paged
word_document: default
pdf_document: default
keep_md: yes
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = F)
```
$$\frac{variable-name}{other-variable-name}$$
But in the document I only recive a "long" Minus sign and not a - "short" hyphen
Thanks for you help.

Change to text mode using \text
$$\frac{variable\text-name}{other\text-variable\text-name}$$

Related

R Markdown: How to use icons

I would like to inlcude Icons at the beginning of my titles in an R markdown script. I found a CV template of a girl that does so, but this does not work for me:
https://github.com/loreabad6/R-CV/blob/master/CV.Rmd
'library(fontawesome)'
\faIcon{university}
I also tried: In `rmarkdown`, how to add icon in sentence?
`r icons::fontawesome("markdown")`
What do I need to do instead?
HTML
You can use the following code to add icons:
---
title: "Untitled"
author: "Author"
date: "2022-08-15"
output: html_document
---
```{r setup, include=FALSE}
remotes::install_github("mitchelloharawild/icons")
icons::download_fontawesome()
```
# This is my title `r icons::fontawesome("markdown")`
Output:
PDF
You can use the latex package fontawesome5. I had to install the package rsvg (just in console) before running the following code:
---
title: "Untitled"
author: "Author"
date: "2022-08-15"
output:
pdf_document:
keep_tex: true
header-includes:
- \usepackage{fontawesome5}
---
# This is my title `r icons::fontawesome("markdown")`
Output:

r - rmarkdown - yaml - Is it possible to include inline, internal document hyperlink in title?

is it possible to include an inline (internal document) hyperlink in the YAML title block of a RMarkdown document? Or is there a R package that allows this?
Below is what I am trying to do:
---
title: blah {#one1} and so on {#two2}
...
---
# Bibliography
1. Reference note to [explain](#one1) in title
2. Reference note to [explain](#two2) in title
Thank you.
The title is parsed as markdown, so you can use regular markdown link syntax in order to get the behavior you want.
---
title: 'There is a link in this title...[LINK](#anchor)'
author: "Jason Punyon"
date: "6/16/2020"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Bibliography
<p id='anchor'>Here's where I went!</p>
You could also just put the link in manually...
---
title: 'There is a link in this title...LINK'
author: "Jason Punyon"
date: "6/16/2020"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Bibliography
<p id='anchor'>Here's where I went!</p>

R Markdown keywords don't appear in the document

I want to knit a pdf-document but the keywords don't appear in the final document. Can someone say me what I'm doing wrong?
---
title: "title"
subtitle: "subtitle"
author: "author"
date: "09 04 2019"
output:
pdf_document:
keywords: "word1, word2, word3"
footerdate: yes
abstract: 'Insert abstract here'
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Introduction
When knitting to PDF, keywords are sent to the file metadata but are not actually visible in the file. Source
You can customize the template for PDF generation or render Rmd files with base_format: rticles::elsevier_article.
However, there is another way to show keywords on the PDF just by adding few codes to the Rmd file:
Add a LaTeX code to provide the \keyword command (\providecommand{\keywords}[1]{\textbf{\textit{Keywords---}} #1}) into YAML's header-includes key;
Add keywords in the text section using the LaTeX command
---
title: "title"
subtitle: "subtitle"
author: "author"
date: "09 04 2019"
output:
pdf_document:
# keywords: "word1, word2, word3" # <- You don't have to add your keywords here since they only appear as the 'invisible' metadata of PDF
footerdate: yes
abstract: 'Insert abstract here'
header-includes:
- |
```{=latex}
\providecommand{\keywords}[1]{\textbf{\textit{Keywords---}} #1}
```
---
```{=latex}
\keywords{word1, word2, word3}
```
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Introduction

Change the caption title of a figure in markdown

I'm currently writing a small report in German. Hence I want my figure caption titles to be changed from Figure 1 to Abbildung 1 and so on.
---
title: "Untitled"
author: "me"
date: '`r format(Sys.time(), "%d %B, %Y")`'
output:
pdf_document: default
---
```{r iris, fig.cap='Iris sepal lengths'}
hist(iris$Sepal.Length)
```
Question: How can I change the default figure title (not sure if it's actually called that way) in R Markdown?
If you are writing in any language other than English, you can change the language options of the outputted pdf with the lang YAML option. This will override all the captions, labels, table of contents etc.
---
output: pdf_document
lang: de
---
```{r iris, fig.cap='Iris sepal lengths'}
hist(iris$Sepal.Length)
```
Other language options include fr (French), it (Italian) etc. See http://pandoc.org/MANUAL.html#language-variables for more details.
Following the example from this question, you can define your own tex file where you can change figure caption defaults.
header.tex:
\usepackage{caption}
\captionsetup[figure]{name=Abbildung}
This is the main .Rmd file:
---
title: "Untitled"
author: "me"
date: '`r format(Sys.time(), "%d %B, %Y")`'
output:
pdf_document:
includes:
in_header: header.tex
---
```{r iris, fig.cap='Iris sepal lengths'}
hist(iris$Sepal.Length)
```

How to link the contents to the actual page in Rmarkdown pdf output

I am creating several reports outputting in a pdf file via calling a markdown file from r. When a pdf file is created I would like to clink in the contents and go to the actual page.
The code that I am using at the moment is :
---
title : "My report"
author: "Myself"
output: pdf_document:
fig_caption: yes
number_section: yes
header-includes:
- \usepackage{wallpaper}
- \usepackage{\wpXoffset}{7.0cm}
- \usepackage{\wpYoffset}{12.5cm}
- \usepackage{longtable}
- \usepackage{hyperref}
---
some text
\newpage
# Introduction
\newpage
# Mytables
```{r, tables,echo = FALSE, results= "asis"}
y= 1;
for (current_table in table$tablename)
{
cat("##",current_schema);
for (current_subtable in subtable$field_name)
name_subtable = paste("###",subtable$field_name[y],"",sep = "");
cat(name_subtable,"\n","&nbsp",fill = TRUE);
y = y + 1
}
```
i.e. When I click on:
Introduction...........................................6
I would like to go at page 6.
Thanks for helping.
Try below code.
---
title : "My report"
author: "Myself"
output:
pdf_document:
fig_caption: yes
number_section: yes
toc: true
header-includes:
- \hypersetup{colorlinks=true, linkcolor=blue}
---

Resources