Change title size with quarto titlepages extension when rendering to pdf - pdf

I am creating a short report with quarto in rstudio, rendering it to pdf. I use the quarto titlepages extension to create a title page with a logo and a background image. I can get everything to work except for the size of the title font.
I've been searching in the web for hours, and trying all approaches I could think off, but the font size of the title never changes...can someone give me a hint on what I am doing wrong?
This is my YAML:
---
title: "Effect of treatment on the species 1"
author: "Author 1 and Author 2"
date: ' `r paste("Date:",Sys.Date())`'
lang: gl
format:
titlepage-pdf:
documentclass: scrbook
titlepage: plain
titlepage-geometry:
- top=70mm
- bottom=30mm
- right=30mm
- left=30mm
titlepage-logo: "images/circularNegro.png"
titlepage-bg-image: "images/OsTres.png"
titlepage-theme:
elements: ["\\titleblock", "\\logoblock", "\\authorblock", "(biólogos colexiados)" ]
page-fontfamily: "Helvetica Neue"
page-align: center
title-fontsize: 30
title-align: center
title-space-after: 3cm
author-fontsize: 16
author-style: plain
logo-align: center
logo-size: 4cm
logo-space-after: 1cm
bg-image-location: "ULCorner"
bg-image-size: 21cm
pdf:
# Fonts
mainfont: Helvetica Neue
fontsize: 12pt
papersize: A4
margin-top: 25mm
margin-bottom: 25mm
margin-left: 25mm
margin-right: 25mm
toc: true
toc-depth: 2
toc-title: Táboa de contidos
editor: visual
---
I tried with title-fontsize: 30 and with title-style: "large" but none of them would change the font size.
I also tried changing the document class from article, to scrartcl and scrbook.
I did also simplify all the YAML and even remove completely the format: pdf: section of it, but title font size did never change.
I finally tried to define title font size with CSS (which I do not know) by including the following chunk after the YAML (based on this question Change title size and color in Quarto (html output)):
```{css, echo=FALSE}
.title {
font-size: 24px;
font-family: "Helvetica Neue";
}
```
When I do that I get the following error:
Unable to locate an installed version of Python 3.

To my understanding, title-fontsize option is not having any effect on the title font size. Because if we run the following,
---
title: "Effect of treatment on the species 1"
author: "Author 1 and Author 2"
date: last-modified
lang: gl
format:
titlepage-pdf:
documentclass: scrbook
titlepage: plain
titlepage-geometry:
- top=70mm
- bottom=30mm
- right=30mm
- left=30mm
titlepage-theme:
elements: ["\\titleblock", "\\logoblock", "\\authorblock", "(biólogos colexiados)" ]
page-align: center
title-fontsize: 50
title-align: center
title-space-after: 3cm
author-fontsize: 16
author-style: plain
keep-tex: true
---
And then checking the underlying intermediate tex file, we can see,
\newcommand{\titleandsubtitle}{
% Title and subtitle
{\fontsize{50}{60.0}\selectfont
{\Large{\nohyphens{Effect of treatment on the species 1}}}\par
}%
}
\newcommand{\titlepagetitleblock}{
\titleandsubtitle
}
Therefore, title font size is actually \Large and our specified font size 50 is having no effect at all.
Therefore, one approach to this issue, could be using title-fontstyle which takes tiny, small, large, Large, LARGE, huge, Huge` as font sizes.
---
title: "Effect of treatment on the species 1"
author: "Author 1 and Author 2"
date: last-modified
lang: gl
format:
titlepage-pdf:
documentclass: scrbook
titlepage: plain
titlepage-geometry:
- top=70mm
- bottom=30mm
- right=30mm
- left=30mm
titlepage-theme:
elements: ["\\titleblock", "\\logoblock", "\\authorblock", "(biólogos colexiados)" ]
page-align: center
title-fontstyle: Huge
title-align: center
title-space-after: 3cm
author-fontsize: 16
author-style: plain
---
Now the aforementioned Huge, LARGE, Large etc. font sizes are LaTeX predefined font sizes. If you want to use custom font sizes other than those, you can define a new fontsize command and then pass it to title-fontstyle option.
So we define a new font size command gigantic with a font size 70 and use this in title-fontstyle: gigantic.
---
title: "Effect of treatment on the species 1"
author: "Author 1 and Author 2"
date: last-modified
lang: gl
format:
titlepage-pdf:
documentclass: scrbook
include-in-header:
text: |
\newcommand{\gigantic}{\fontsize{70}{73}\selectfont}
titlepage: plain
titlepage-geometry:
- top=70mm
- bottom=30mm
- right=30mm
- left=30mm
titlepage-theme:
elements: ["\\titleblock", "\\logoblock", "\\authorblock", "(biólogos colexiados)" ]
page-align: center
title-fontstyle: gigantic
title-align: center
title-space-after: 3cm
author-fontsize: 16
author-style: plain
---
And lastly some remarks about your attempt of using CSS,
You can not use CSS to modify anything that will be rendered as pdf. You have to use either latex commands or pandoc options.
And you are facing that error, because you are using css chunk which quarto finds as the very first code chunk in the qmd file while rendering the document and as a consequence, Quarto will try to render this document using jupyter which requires python installation. To avoid this problem, one need to use engine: knitr. But again, you do not need a css chunk while rendering to pdf format at the first place.

Yes, it is a rather confusing problem that I wasn't sure how to solve. The title-fontsize is being overridden by title-fontstyle. You need to set title-fontstyle: [] This will work:
---
title: "Test page title font size"
date: last-modified
format:
titlepage-pdf:
documentclass: scrbook
titlepage: plain
titlepage-theme:
title-fontsize: 50
title-align: center
title-fontstyle: []
keep-tex: true
---
I considered doing a check if title-fontsize is spec-ed and then check if any fontsize is being set in title-fontstyle and disallow that. But I haven't coded that. I am thinking perhaps to just 'outlaw' any fontsize in title-fontstyle and require title-fontsize for that. The only problem is that you also need to set title-fontspacing; there is a default, but it doesn't always look good. Maybe I should just issue a warning if title-fontsize is set and title-fontstyle has a fontsize specified.

Related

Inline math font size and equations spacing in markdown to pdf conversion using pandoc

I'm using vim and markdown as an alternative to obsidian. I'm doing the conversion from markdown to pdf using pandoc and I would like to resemble as much as possible the pdf output of obsidian since I like how it looks.
In general I could make both pdf looks almost the same, but, I got two problems, the first is that the inline math font is too big, the second that the spacing before and after an equation is different.
Here are two screenshots, the first one being the pandoc output, the second the obsidian output.
To style the pdf I'm using a custom latex snippet which I include with pandoc -H style.tex ... during the pdf compilation, with this I was able to change the spacing between the text and the sections title as well as other things like page margins, etc. But I didn't find anything related to the math nor the equation for a template
I've also tried writing the equation as $\small \vec{E}$ but didn't work.
I think it has to be a way of changing the spacing from the latex template, I know that pandoc is using the unicode-math package to convert the latex equations but didn't find nothing related on how to change the spacing for the equations nor the font size.
EDIT: the style.tex file
% page setup
\usepackage[a4paper,
top=2cm,
bottom=1.75cm,
left=1.75cm,
right=1.75cm]{geometry}
\usepackage{titlesec}
\usepackage{fontspec}
% inline code (backticks in md)
% taken from https://jdhao.github.io/2019/05/30/markdown2pdf_pandoc/
\linespread{1.15}
\definecolor{bgcolor}{HTML}{e0e0e0}
\let\oldtexttt\texttt
\renewcommand{\texttt}[1]{
\colorbox{bgcolor}{\oldtexttt{#1}}
}
% change boldfont bold to extrabold
% \setmainfont[
% BoldFont={Inter-ExtraBold}
% ]{Inter}
% change regular font to light font
% \setmainfont{Inter light}
\newfontfamily\titlefont{Inter}[
UprightFont = *-Regular,
BoldFont = *-ExtraBold,
]
\newfontfamily\sectionsfont{Inter}[
UprightFont = *-Regular,
BoldFont = *-SemiBold,
]
\titleformat{\section}
{\titlefont\huge\bfseries}
{}
{0em}
{}
\titleformat{\subsection}
{\sectionsfont\LARGE\bfseries}
{}
{0em}
{}
\titleformat{\subsubsection}
{\sectionsfont\Large\bfseries}
{}
{0em}
{}
\titleformat{\paragraph}
{\sectionsfont\large\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\subsubsection}
{0pt}{2.5ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titleformat{\subparagraph}
{\normalfont\large\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\subparagraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
EDIT2: this is the .tex output part showed in the screenshot
taken from:
pandoc --pdf-engine=xelatex file.md -o file.tex
eléctrica que efectúa el campo sobre la partícula. se puede calcular entonces como:
\[\frac{w_{a \rightarrow b}}{q_{0}} = - \int_{a}^{b} \vec{e} \cdot d\vec{l} = v_{b} - v_{a} = v_{ab}\]
donde \({q_{0}}\) es una pequeña carga puntual, \(v_{a}\) y \(v_{b}\) el potencial por unidad de carga de los puntos \(a\) y \(b\) respectivamente, \(\vec{e}\) el valor del campo eléctrico

Short header for a very long Section's title in beamer presentation R Markdown (Pandoc)

I am working on a beamer_presentation which consists of several sections. The section titles are too long to fit into the CambridgeUS headline. I have already tried several options from related latex sources to use some short title for the section (say just "Chapter 1" instead of "Chapter 1 with a very-very-very-very-very long title" by \AtBeginSection{\title[Short title]{Long title}}) but yet can't figure out how to manage this in header-includes of R Markdown YAML. I set the section title through # in Markdown
---
title: Title for the whole presentation
subtitle: 'Presentation'
author:
- Author
institute: "Institution"
date: " `r format(Sys.Date(), '%B %d, %Y')`"
output:
beamer_presentation:
latex_engine: xelatex
toc: true
highlight: tango
theme: "CambridgeUS"
colortheme: "lily"
fonttheme: "serif"
slide_level: 3
keep_tex: true
header-includes:
- \setbeamertemplate{navigation symbols}{}
- \AtBeginDocument{\title[Presentation]{Title for whole presentation}}
- \renewcommand{\raggedright}{\leftskip=0pt \rightskip=0pt plus 0cm}
- \def\sectionname{Chapter}
- \AtBeginSubsection{}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
```
# Chapter 1 with a very-very-very-very-very long title
## Intro
### The first page
In beamer, this is trivial, you can use \section[short version]{long version}. But Markdown makes such an easy job excruciatingly difficult.
However you can trick markdown like this:
---
title: Title for the whole presentation
subtitle: 'Presentation'
author:
- Author
institute: "Institution"
date: " `r format(Sys.Date(), '%B %d, %Y')`"
output:
beamer_presentation:
latex_engine: xelatex
toc: false
highlight: tango
theme: "CambridgeUS"
colortheme: "lily"
fonttheme: "serif"
slide_level: 3
keep_tex: true
header-includes:
- \setbeamertemplate{navigation symbols}{}
- \AtBeginDocument{\title[Presentation]{Title for whole presentation}}
- \renewcommand{\raggedright}{\leftskip=0pt \rightskip=0pt plus 0cm}
- \def\sectionname{Chapter}
- \AtBeginSubsection{}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
```
```{=latex}
\tableofcontents[hideallsubsections]
\end{frame}
\section[short version for headline]{Chapter 1 with a very-very-very-very-very long title}
\subsection[short subsection for headline]{Intro}
\begin{frame}
\frametitle{The first page}
```
some text
(be careful where you place this command, otherwise you might end up with empty extra frames - that's why I had to switch off the automatic toc and insert it manually...)

How to conditionally set header and footer of pages?

It's my first time using reportlab to generate pdfs, it's VERY hard for me to understand how it works (it took me a day to even put a sized SVG image :D)
I want to achieve a very basic pdf:
As you can see in the images: 1 cover page, then 2 pages with header and footer BUT header with text is only on the first page...
Text is not static at all, it can break up to 4-5 pages, in the future there could be another section with title with different text.
Also I think what is very hard is to set text's Frame.topPadding to be variable based on
header height... I can't even imagine how to do this xD
This is my code right now
I've achieved to do the first page, it was pretty easy, but when it came to Frames, PageTemplates and other, my head blew up...
def _header(self, canvas, doc, title=None):
# Save the state of our canvas so we can draw on it
canvas.saveState()
y_pad = 50
header_height = (y_pad * 2) + (self.styles['heading'].leading if text else 0)
header_frame = Frame(
x1=0,
y1=self.height - header_height,
width=self.width,
height=header_height,
topPadding=y_pad,
bottomPadding=y_pad
)
canvas.setFillColor(DARKGRAY)
canvas.rect(0, self.height - header_height, self.width, header_height, fill=1)
if text:
header_frame.addFromList([
Paragraph(text, self.styles['heading'])
], canvas)
# Release the canvas
canvas.restoreState()
def _dark_page(self, canvas, doc):
canvas.saveState()
canvas.setFillColor(DARKGRAY)
canvas.rect(0, 0, self.width, self.height, fill=1)
canvas.restoreState()
def _create(self):
doc = SimpleDocTemplate(
self.buffer,
topMargin=0,
rightMargin=0,
leftMargin=0,
bottomMargin=0,
pagesize=A4
)
story = []
# cover page template with dark background set by self._dark_page
main_page_template = PageTemplate(id='main', frames=[
Frame(0, 0, self.width, self.height, 0, 100, 0, 100)
], onPage=self._dark_page)
# basic page template for any further text about product
body_page_template = PageTemplate(id='body', frames=[
Frame(0, 0, self.width, self.height, 80, 120, 80, 120, showBoundary=1)
], onPage=lambda c,d: self._header(c, d, title='title title title title')
doc.addPageTemplates([main_page_template, body_page_template])
story.append(NextPageTemplate('main'))
logo = svg2rlg(LOGO_PATH)
logo.width = logo.minWidth() * 0.4
logo.height = logo.height * 0.4
logo.scale(0.4, 0.4)
# logo._showBoundary = 1
logo.hAlign = 'CENTER'
story.append(logo)
story.append(Spacer(width=0, height=80))
# maybe there's a way to position the image in the center between elements,
# like justify-content: between in css...
image = Image(self._get_product_image_path(), 320, 320)
story.append(image)
story.append(Spacer(width=0, height=80))
title = Paragraph(self.product.title, self.styles['heading'])
story.append(title)
if self.product.breed.name_latin:
story += [
Spacer(width=0, height=10),
Paragraph(self.product.breed.name_latin, self.styles['subheading'])
]
story.append(NextPageTemplate('body'))
story.append(PageBreak())
# actual text
story.append(Paragraph(text*4, self.styles['body']))
doc.build(story)
So the question is
How do I set header and footer on the page, and if page breaks, next page with same header and footer, but header without title until the last page of the PageTemplate?
I've tried to get page numbers in self._header doc argument, but it's returning the first page number of the PageTemplate, not every page, maybe there's a way to get a page number from 0(first page used by some template) to the last page used by this template?
THANKS in advance! It already took me 3 days to try to achieve this...

Rmarkdown knit pdf - getting underlined text instead of italic using *italic* (huxtable issue?)

Rmarkdown text (between chunks) when formated italic using * * knits to pdf underlined and not italic format when I print huxtable.
Here is my example:
```
---
title: "<center><center>"
author: "<center> jd <center><br>"
date: "<center> `r Sys.Date()` <center>"
output:
pdf_document:
fig_caption: yes
toc: yes
toc_depth: 3
number_sections: true
latex_engine: xelatex
html_document:
code_folding: show
df_print: paged
theme: yeti
highlight: tango
toc: yes
toc_float:
collapsed: false
smooth_scroll: false
number_sections: true
fontsize: 10pt
---
This * * makes text *italic*.
```{r lib, message = FALSE}
library(huxtable)
library(tidyverse)
data(iris)
dt_hux <- iris[1:5,1:5] %>% as_hux() %>%
set_font_size(8) %>% set_font("Arial") %>%
set_bold(1, everywhere) %>%
set_top_border(1, everywhere) %>%
set_bottom_border(c(1, 6), everywhere)```
Until this point using * * will give italic format in knit pdf (if next chunck is not run).
But after the next chunk is run * * will underline text (in whole Rmarkdown). Commenting out **dt_hux** returns formatting to italic. Also knit to html will print italic formatting even with dt_hux.
```{r table}
options(huxtable.latex_use_fontspec = TRUE)
options(huxtable.print=print_latex)
dt_hux```
```
Is there a solution to this issues as I need to print huxtable in pdf?
From the TeXnical perspective the problem is that the ulem package is loaded without the normalem option. A couple of workarounds:
use classoption: normalem (based on Knitr hook to add code before \documentclass line in tex file to avoid options clash with xcolor). Caveat: this will pass the option to all packages and might be undesired in case the same option name is also used by other packages (I'm not aware of any other package that uses this option, but just in case ...)
add \normalem either as header-include or at the start of your document
This problem was fixed in huxtable 5.2.0, so you just need to update your package.

REBOL Change the backdrop image and text

REBOL
I currently trying to redo a small app I made in Delphi.
This application displays a background image among n and a text among n, but I cannot change the image or the text, the change of image and text is done by the button >>.
This is the simplified code without the random part because I found out about it:
Rebol[
Title: "You have a message !"
Version: 1.0.0
Needs: [1.2.115]
]
the-imag1: load %"/C/MyFile/Cours CD/Affiche/Images/Vague9.jpg"
the-imag2: load %"/C/MyFile/Cours CD/Affiche/Images/Vague3.jpg"
the-image: the-imag1
text1: "Your banner text here"
view xx1: layout [
size the-image/size
b1: backdrop the-image
at b1/offset + 110x120
box 350x150 font-size 20 font-color black [align: 'center] text1
at b1/offset + 530x370
btn ">>" [the-image: the-imag2 ; new image
text1: "Hello" ; new text
show xx1] effect [multiply 90]
]
You are redefining the face, not just the content. Just redefine the field you need. Try this:
Rebol[
Title: "You have a message !"
Version: 1.0.0
Needs: [1.2.115]
]
the-imag1: load %"/C/MyFile/Cours CD/Affiche/Images/Vague9.jpg"
the-imag2: load %"/C/MyFile/Cours CD/Affiche/Images/Vague3.jpg"
the-image: the-imag1
text1: "Your banner text here"
view xx1: layout [
size the-image/size
b1: backdrop the-image
at b1/offset + 110x120
t1: text text1
at b1/offset + 530x370
btn ">>" [
b1/image: the-imag2 ; new image
t1/text: "Hello" ; new text
show xx1
] effect [multiply 90]
]