Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matplotlib image does not apepar on margin in pdf #6863

Closed
finkelshtein opened this issue Sep 17, 2023 · 5 comments · Fixed by #6865
Closed

Matplotlib image does not apepar on margin in pdf #6863

finkelshtein opened this issue Sep 17, 2023 · 5 comments · Fixed by #6865
Assignees
Labels
Milestone

Comments

@finkelshtein
Copy link

Hi,

I'd like to use Tufte style with Matplotlib images for both HTML and PDF. The following code produce expected HTML, however, in PDF, the image is placed in the main text, not at the margin.

---
title: "matplotlib demo"
format:
  html: 
      self-contained: true
      grid: 
          margin-width: 350px
  pdf: default
jupyter: python3
---

Demo

```{python}
#| echo: false
#| column: margin

import matplotlib.pyplot as plt

plot = plt.figure()
plot.set_figwidth(2)
plot.set_figheight(3)

x = [1, 2]
y = [2, 3]

plt.plot(x,y)

```

Looking at the Latex-file, I can see that \marginnote is just absent. When I try to enclose the code into another {.column-margin} div:

::: {.column-margin}
```{python}

code

```
::: 

it still works in HTML, but it makes error in PDF, as it produces Latex figure environment inside \marginnote.

  1. Is it a bug, or I missed an option?
  2. Is it possible to get an output of Matplotlib without placing it into figure?
  3. Otherwise, I will probably need to export image from the Python code and import it inside {.column-margin}.

Many thanks!

@jjallaire jjallaire transferred this issue from quarto-dev/quarto Sep 17, 2023
@jjallaire
Copy link
Collaborator

cc @dragonstyle

@dragonstyle
Copy link
Collaborator

This appears to be related to some recent work in Quarto related to handling of figures and cross references. Thanks for letting us know we'll get it fixed asap! (worked in 1.4.358).

@dragonstyle dragonstyle added this to the v1.4 milestone Sep 17, 2023
@cscheid
Copy link
Collaborator

cscheid commented Sep 17, 2023

The bug is that columns-preprocess.lua is not correctly forwarding the classes into the custom AST nodes.

@cscheid
Copy link
Collaborator

cscheid commented Sep 17, 2023

Thank you for the report and reproduction! PR with fix is up on #6865, will be merged once tests pass.

@cscheid
Copy link
Collaborator

cscheid commented Sep 17, 2023

Thank you so much for the report again. We fixed the bug on main and will have a new prerelease binary shortly.

cscheid added a commit that referenced this issue Sep 17, 2023
* regression: forward classes correctly. Closes #6863
* add test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants