Set PDF Options in Julia Markdown - pdf

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"])

Related

Create a multiple page orientation in a single quarto PDF output

The idea is to replicate the PDF output on rmarkdown in quarto, in this case, is creating a multiple-page orientation on a single document. In rmarkdown I can do it easily by using this trick. However, I could not do that in quarto, it keeps sending the error message
compilation failed- error
Undefined control sequence.
l.201 \blandscape
Here is my code:
---
title: "Portrait and Landscape"
format:
pdf:
include-in-header:
- packages.tex
---
# Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
\newpage
\blandscape
# Running Code
When you click the **Render** button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
You can add options to executable code like this
The `echo: false` option disables the printing of code (only output is displayed).
\elandscape
Interestingly, I can create a multiple page orientation by modified the YAML and inserting raw latex to start and end the landscape page, but it will erase all the rmarkdown formatting and turned it into normal text inside the landscape page:
---
title: "Portrait and Landscape"
format:
pdf:
include-in-header:
text: |
\usepackage{pdflscape}
---
\begin{landscape}
bla bla bla
\end{landscape}
Is there any workaround on this matter?
PS: my header.tex contains this stuff
\usepackage{pdflscape}
\newcommand{\blandscape}{\begin{landscape}}
\newcommand{\elandscape}{\end{landscape}}
Option 01
You can use lscape LaTeX package. This rotates the page contents but not the page number.
---
title: "Portrait and Landscape"
format:
pdf:
include-in-header:
text: |
\usepackage{lscape}
\newcommand{\blandscape}{\begin{landscape}}
\newcommand{\elandscape}{\end{landscape}}
---
# Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
\newpage
\blandscape
# Running Code
When you click the **Render** button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
You can add options to executable code like this
The `echo: false` option disables the printing of code (only output is displayed).
\elandscape
Option 02
You can also use typearea package of KOMA-Script to do this. To my understanding, It not just changes the page contents orientation, but also sets the pdf page rotation attribute in such a way that pages with this attribute will be displayed in landscape orientation when viewing with PDF viewers. And also preserves the page number position.
---
title: "Portrait and Landscape"
format:
pdf:
include-in-header:
text: |
\usepackage{typearea}
---
# Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
\newpage
<!-- changing the orientation to landscape --------------------------------- -->
\KOMAoptions{paper=landscape,pagesize}
\recalctypearea
# Running Code (Landscape)
When you click the **Render** button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
You can add options to executable code like this
The `echo: false` option disables the printing of code (only output is displayed).
\newpage
<!-- % changing the orientation to portrait again -------------------------- -->
\KOMAoptions{paper=portrait,pagesize}
\recalctypearea
# Quarto (Portrait)
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.

Specify custom fonts and attributes for H1-H6 headings in quarto PDF

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>.

Remove italics (# comments) in Rmarkdown code chunks in pdf

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.

How to Set Default Yaml For R Markdown Documents?

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.)

Change font size of ATX-header in markdown

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}