I am looking to find a way to remove the italicized comments in Rmarkdown code chunks
---
output:
pdf_document:
keep_tex: true
number_section: no
---
```{r}
# This is a test.
```
And the results.
Is there a way to make it not italicized?
Thank you,
Several code highlight styles do not italicize the comments, including haddock, kate, and zenburn. See here for a preview of available styles.
---
output:
pdf_document:
keep_tex: true
number_section: no
highlight: kate
---
If you need to create a custom syntax highlighting theme, instructions in the pandoc manual are here.
Related
I am writing a report.pdf in R Markdown and want to include a pdf as a figure.
The chunk looks like this:
include_graphics("path/to/figure.pdf")
The chunk works fine, but since the figure has a white margin, it is not clear on the output page where the figure starts/ends. Therefore, I would like to add a simple frame around the figure.
Does knitr provide that option?
I've looked for similar questions on rseek.org, scanned through Yihui's book on bookdown and searched the knitr package documentation without finding anything helpful.
Following this post:
---
output: pdf_document
header-includes: |
\usepackage[export]{adjustbox}
\let\includegraphicsbak\includegraphics
\renewcommand*{\includegraphics}[2][]{\includegraphicsbak[frame,#1]{#2}}
---
```{r}
knitr::include_graphics("images/example.pdf")
```
Result:
I would like to set different sizes and styles of the free overpass font for the H1 & H2 headers in my document.
Using this answer I was able to successfully specify Overpass for all headings in my document but have not been able to isolate specific headings (e.g., chapter, section, paragraph as laid out in the Koma script.
I tried implementing the syntax from this solution used to specify times roman for all heading fonts, but got an error that reads "Package scrkbase Error: font of element `chapter' can't be used.".
Looking at the quarto forum and this tex post, I tried adding the xltxtra packages and setting \newfontfamily, but still no luck.
Ultimately, I would like to use the overpass extra bold font and specify different sizes, but i'm unsure if this is because the syntax to specify the heading section in the YAML is wrong, or if I need to do something else to add a font that is not already built in.
format:
pdf:
mainfont: Calibri
sansfont: Overpass
include-in-header:
text: |
\usepackage{xltxtra}
\newfontfamily\overpass{Overpass}
\usekomafont{chapter}{\Overpass-ExtraBold}
standalone: false
toc: true
editor: visual
tbl-colwidths: auto
include-in-header:
text: |
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\rhead{\includegraphics[width = .25\textwidth]{logo.png}}
\cfoot{\thepage}
\usepackage{float}
We can create new commands like \sectionfont or \subsectionfont for loading a particular font family with \newfontfamily (read the fontsepc manual, p-13 to know the details) and then use that command \addtokomafont to apply that font-family to a specific element like (section, subsetion, etc.)
---
format: pdf
mainfont: "Calibri"
include-in-header:
text: |
\newfontfamily\sectionfont[Color=ff7832]{Libertinus Sans}
\newfontfamily\subsectionfont[Color=MediumBlue]{Comic Sans MS}
\newfontfamily\subsubsectionfont[Color=Green]{Roboto Mono}
\addtokomafont{section}{\sectionfont}
\addtokomafont{subsection}{\subsectionfont}
\addtokomafont{subsubsection}{\subsubsectionfont}
---
# H1 heading (section)
## H2 heading (subsection)
### H3 heading (subsubsection)
Quarto enables you to weave together content and executable code into a
finished document. To learn more about Quarto see <https://quarto.org>.
I have a Julia Markdown file (jmd).
---
title: My Title
output: pdf_document
---
```julia echo=false
6+4
```
How can I transport information to LaTex? For example I would like to set the paper orientation to landscape or decrease the font size or similar. I thought be there must be something similar to Rmarkdown, something like
---
title: My title
output:
pdf_document:
toc: true
number_sections: true
documentclass: article
classoption: landscape, a3paper
---
But it does not work in jmd files. Anyone a clever idea?
Setting Configurations on Two Fronts
Weave Options
weave_options can be specified in a Julia Markdown Document's front matter. These are options that might otherwise be passed to the weave function as keyword arguments (configuration in front matter takes precedence over function call options). E.g., one can define the doctype and highlight options. Optionally, one may also define a custom latex template. The following front matter would set these options.
---
title: My Title
author: Me
date: March 21, 2022
weave_options:
doctype: pandoc2pdf
highlight: pygments
template: relative/path/to/custom.tpl
---
Pandoc Options
Assuming that your working with doctype: pandoc2pdf or doctype: pandoc2html then you can also set Pandoc options by passing them as a vector of strings to the pandoc_options keyword argument of the weave function. E.g., for a table of contents and numbered sections one could run the following.
weave("test.jmd", pandoc_options=["--toc", "-N"])
This is what I typically put at the top of my documents in R markdown:
---
title: Title
author: Amar Al-Zubaidi
date: \today
mainfont: Inconsolata Nerd Font
sansfont: Inconsolata Nerd Font
monofont: Inconsolata Nerd Font
fontsize: 11pt
table-use-row-colors: true
bibliography: /home/amarakon/Documents/bibliography.bib
csl: /home/amarakon/Documents/Citations/apa-no-initials.csl
classoption: letterpaper
output:
pdf_document:
keep_tex: true
latex_engine: xelatex
template: eisvogel
number_sections: true
---
I do pretty much the same thing for every document.
In fact, the only thing I change for every document is the title.
I want to know how I can put all of these values in a file (except for the title), and change my compile command to read that file when compiling. This is the command I use to compile:
R -e "rmarkdown::render('file.Rmd')"
My end goal is to only have to put something like this in my Rmarkdown document:
---
title: my-title
---
I answered a similar question not that long ago using this information.
Since I had worked on that question, I only had to clone my last template and update the skeleton to create your template.
You won't have a YAML with just your title. However, all of the elements that you specified you wanted would be pre-written in the RMD file when you open a new file using this template.
You can see this repository at fraupflaume/customYAML2.
To install this template (it's not a package per se; there's no library):
devtools::install_github("fraupflaume/customYAML2")
When you want to start a new RMD script, go to templates -> Custom YAML -> customYAML2.
If you wanted to change this down the road, you can fork or clone that repository and edit it to your heart's content.
BTW:: let me know if you want me to remove the images. (It has your name in them: here and on Github.)
I am writing a book with bookdown. Unfortunately, I have no clue how to format (e.g. setting font size) ATX-hearder (#, ##, ## etc.). So far, it does not work via pandoc or preamble.tex.
I have tried the following, with regard to this.
Unfortunately, there is an error message :
\usepackage{titlesec} \titleformat{\chapter}[display] {\normalfont\sffamily\huge\bfseries\color{blue}} {\chaptertitlename\ \thechapter}{20pt}{\Huge}
Thanks in advance!
Your best bet here is to add a LaTeX preamble to the document. In here, you can define the required LaTeX packages. Two changes are made to the base template:
We need to add subparagraph: true to make titlesec work with R Markdown, as explained here
# refers to a level one header in pandoc, and therefore you need to make the style changes for section not chapter https://www.sharelatex.com/learn/Sections_and_chapters
Here is a minimal example
---
output:
pdf_document:
includes:
in_header: header.tex
subparagraph: true
---
# Section
## Subsection
The preamble.tex file is saved in the same directory:
\usepackage{titlesec}
\usepackage{color}
\titleformat*{\section}{\LARGE}
\titleformat{\subsection}[display]
{\normalfont\sffamily\huge\bfseries\color{blue}} {\chaptertitlename\ \thechapter}{20pt}{\Huge}