4

I do not get the syntax for resizing graphics in Quarto, could you please give me a hint. The following has no effect.

---
title: "resize image"
format: pdf
---

![World](images/World.pdf){fig-width=5}

![World](images/World.pdf){fig-width=10}

![World](images/World.pdf){fig-width=50%}

![World](images/World.pdf){fig-height=50%}

https://quarto.org/docs/reference/formats/pdf.html#figures

https://quarto.org/docs/authoring/figures.html

ckluss
  • 1,477
  • 4
  • 21
  • 33

1 Answers1

5

You can use width and height, as documented here.

---
title: "resize image"
format: pdf
---

![Elephant with small width](elephant.png){width=10%}

![Elephant with larger height](elephant.png){height=50%}

You can also use px and in as the unit, or specify it between quotes:

![Elephant with height=100px](elephant.png){height=100px}

![Elephant](elephant.png){height=2in}

![Elephant](elephant.png){height="100"}

Why are fig-height and fig-width not working?

As stated in the document you cite, fig-height and fig-width are settings for the default size for figures generated by R or Matplotlib graphics.

Since your image is not generated by R or Matplotlib, you should use pandoc's attributes, as documented here.

Maël
  • 45,206
  • 3
  • 29
  • 67
  • But this won't be a figure element. How can one control the figure element height? – Royi Dec 12 '22 at 14:24
  • With `fig-height`. For it to be a figure element, it has to be the result of a command in R, not with Markdown, e.g. using `jpg::readJPG` or `png::readPNG`. – Maël Dec 12 '22 at 14:29
  • I understand that `fig-height` won't work. I am asking how to control the height of a specific figure. – Royi Dec 12 '22 at 18:14
  • Note if you are using a chunk option it is out-width and out-height! – see24 Mar 23 '23 at 14:07