Tricks to use Quarto for publishing: Control line breaks, page numbers, positions of images, German quotation marks, cover image

I use Quarto to publish essays for the Forum Queer Archive München. Here are a few useful commands to give you more layout control.

Start a new page

Pretty self-explanatory: Add \newpage where you want a new page to start.

No page numbers on specific pages

Imagine you don’t want a page number to be inserted on the table of contents page, for example. The solution is to combine \newpage with \thispagestyle{empty}.

A minimal example:

title: "Toc page has no page number"
    toc: true



## Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <>.

## 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:

This also works on any page within the document.

Line breaks in title blocks

Sometimes you need a (line) break within the yaml header information, like title, subtitle, author, … . Solution: Add some |’s.

Linebreaks like <br>

subtitle: |
    | I am a subtitle
    | with a line break

Sometimes you just need some space. Add just a \ for every empty line.

More control over image positioning

LaTex, the technology used by Quarto to render PDFs, positions images automatically.

One common frustration with LaTeX is the placement of figures and tables. Unlike in a word processor like Microsoft Word, in which figures are placed directly where the user specifies, LaTeX will attempt to place a figure in a position that does not violate certain typographic rules.

R Markdown Cookbook

This can lead to an image not being in the place in the PDF layout where you have inserted it. If you want to overrule this, you need the LaTeX package float.

You have to include the package in the yaml header and then declare the position per image with fig.pos.

    extra_dependencies: ["float"]
![This plot should be exactly, where I said it should be.](plot.png){fig.pos="H"}

More on this in the R Markdown Cookbook.

Use German quotation marks

You have to include a LaTex package in your yaml header:

  - \usepackage{csquotes}

And then add quotation marks like that to get those nice „ and “ quotation marks.

\enquote{I am a quote}

Add a cover image

This is a tricky one. I want to use a cover image, that was produced independently of the Quarto document.
First, I tried popplers pdfunite command, but it breaks the links in the table of content. Then I tried the quarto_titlepages extension: It seems to be capable of a lot, but also changes the font styles somehow…

I ended up doing this:

Using the LaTex pdfpages, I add the cover image pdf as a first page, which is in the end the second page after the title page:

  - \usepackage{pdfpages}

Then I drag that 2nd page to the top position in MacOS Preview app. A bit unsatisfactory, but the links in the table of contents work.

Schreibe einen Kommentar