animation.hook is ignored for LaTeX output in the knitr engine

Aperta
#14,814 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
latex, r

Direzione di ricerca

Start in src/resources/rmd/hooks.R, especially latex_animation(), the animation dependency handling, and the linked hook setup; then inspect src/resources/schema/cell-figure.yml. Compare the current logic with knitr's hook_plot_tex() behavior. Done means a non-built-in animation.hook is honored for LaTeX/PDF output and the animate dependency is not added when that hook supplies the output.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

engines-knitr enhancement figures latex

The animation.hook chunk option works for HTML output but has no effect for LaTeX/PDF output.

For a chunk with fig.show: animate, we only inject a default hook when the format is not LaTeX

https://github.com/quarto-dev/quarto-cli/blob/d4cb49f1e70fb34e4cdf38edbb2f938c3ce7cc21/src/resources/rmd/hooks.R#L115-L126

The HTML branch then delegates to knitr's hook_animation(), so a user-supplied hook is honored there. The LaTeX branch instead calls our own latex_animation(), which always emits \animategraphics{} and never looks at animation.hook

https://github.com/quarto-dev/quarto-cli/blob/d4cb49f1e70fb34e4cdf38edbb2f938c3ce7cc21/src/resources/rmd/hooks.R#L1170-L1206

It also adds a dependency on the LaTeX animate package unconditionally

https://github.com/quarto-dev/quarto-cli/blob/d4cb49f1e70fb34e4cdf38edbb2f938c3ce7cc21/src/resources/rmd/hooks.R#L713-L718

Upstream knitr changed this in yihui/knitr#2452: hook_plot_tex() now calls a user-supplied animation.hook (or the package option animation.fun) to generate the LaTeX code, so LaTeX packages other than animate can be used, xmpmulti for beamer overlays being the motivating example. The built-in hooks (ffmpeg, gifski, scianimator, r2swf) generate HTML and keep being ignored for LaTeX. Our latex_animation() is a port of knitr's code from before that change.

So with the next knitr release this will work in .Rmd but not in .qmd.

We could port the same logic into latex_animation(): when animation.hook is a function and is not one of knitr's built-in HTML hooks, call it instead of emitting \animategraphics{}, and skip the animate dependency in that case.

Two things to sort out if we do this. Our schema documents animation-hook with default: ffmpeg while we actually inject gifski for non-LaTeX output, and it is typed as a string with completions, so a function can only be passed with the classic R chunk syntax ({r, animation.hook=my_hook}) and not with #| YAML.

https://github.com/quarto-dev/quarto-cli/blob/d4cb49f1e70fb34e4cdf38edbb2f938c3ce7cc21/src/resources/schema/cell-figure.yml#L219-L235

Lingua principale
JavaScript
Stelle
6k
Fork
458
Merge medio
1g 9h
PR unite (30g)
41

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di quarto-dev/quarto-cli

Tutte le issue di quarto-dev/quarto-cli

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.