quarto-dev / quarto-dev/quarto-cli

global fig-align rule not respected by images without a caption

Open
#6,509 9 comments 2 reactions 1 assignee View on GitHub

@cscheid is already working on this.

Since Aug 14, 2023.

crossref enhancement figures latex
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

Bug description

If I define the global rule fig-align=center in the front matter, in the pdf produced by latex only images with captions are centered. Figures without caption are left-aligned.

The same thing happens if I set right alignment.

Steps to reproduce
---
title: "Test figure alignment"
format:
  pdf:
    fig-align: center
---

# Title

With caption

![With caption!](images/Placeholder.png)

Without caption

![](images/Placeholder.png)

Then
quarto render test.qmd --to-pdf

Expected behavior

All figures should be centered.

Actual behavior

Figures without caption are not centered.
Inspecting the latex source, I realized that the problem is the following.
Figures with caption are rendered this way

\begin{figure}
{\centering \includegraphics{images/Placeholder.png}
}
\caption{With caption!}
\end{figure}

But figures without caption are rendered this way:

\includegraphics{images/Placeholder.png}

Note that if a figure without caption is individually centered, ![](images/Placeholder.png){fig-align="center"}, all works well because the latex source is

\begin{figure}
{\centering \includegraphics{images/Placeholder.png}
}
\end{figure}
Your environment
  • IDE: VSCode 1.81.1
  • OS: Windows 10 Version 22H2 (build SO 19045.3324)
Quarto check output
[>] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.1: OK
      Dart Sass version 1.55.0: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
      Version: 1.3.450
      Path: C:\Users\rdima\scoop\apps\quarto\current\bin
      CodePage: 1252

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....(None)

      Unable to locate an installed version of Python 3.
      Install Python 3 from https://www.python.org/downloads/

[>] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.