quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.74k stars 305 forks source link

Embedded tables are not rendering in parent quarto document #7210

Closed atsyplenkov closed 8 months ago

atsyplenkov commented 11 months ago

Bug description

I am attempting to embed a table from one .qmd file into another .qmd file (parent document). However, regardless of how the table is rendered (using kable, gt, or hux), the embedding process causes the rendering to fail with the following errors. Individually, each quarto document renders successfully to .html.

processing file: index.qmd

output file: index.knit.md

Rendering qmd embeds
[1/1] notebooks/inset-table.qmd

processing file: inset-table.qmd

output file: inset-table.knit.md

ERROR: The notebook notebooks/inset-table.qmd doesn't contain output to embed with the cell id, tag, or label 'tbl-two'. Please be sure to have executed any cells that you are embedding.

Stack trace:
    at file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:69578:23
    at Array.map (<anonymous>)
    at notebookMarkdown (file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:69573:40)
    at eventLoopTick (ext:core/01_core.js:181:11)
    at async replaceNotebookPlaceholders (file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:69517:32)
    at async renderPandoc (file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:69873:28)
    at async Object.onRender (file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:76312:36)
    at async renderFileInternal (file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:76289:17)
    at async renderFiles (file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:76084:17)
    at async render (file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:81071:21)

Steps to reproduce

There are two documents. One is the parent document, the second is the supplementary document (named inset-table.qmd).

Parent document

---
title: "Test of embedding tables"
format:
  html:
    toc: true
---

Hello world

```{r}
#| label: tbl-one
#| tbl-cap: This is normal gt table

gt::gt(head(mtcars))

{{< embed inset-table.qmd#tbl-two >}}


# Supporting document (`inset-table.qmd`)

````qmd
---
title: "Notebook"
---

```{r}
#| label: tbl-two
#| tbl-cap: THis is embed example

gt::gt(head(mtcars))

### Expected behavior

There should be two tables printed using the `gt` package in the parent document.

### Actual behavior

Quarto crashes with the following error

```bash
processing file: index.qmd

output file: index.knit.md

Rendering qmd embeds
[1/1] notebooks/inset-table.qmd

processing file: inset-table.qmd

output file: inset-table.knit.md

ERROR: The notebook notebooks/inset-table.qmd doesn't contain output to embed with the cell id, tag, or label 'tbl-two'. Please be sure to have executed any cells that you are embedding.

Stack trace:
    at file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:69578:23
    at Array.map (<anonymous>)
    at notebookMarkdown (file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:69573:40)
    at eventLoopTick (ext:core/01_core.js:181:11)
    at async replaceNotebookPlaceholders (file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:69517:32)
    at async renderPandoc (file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:69873:28)
    at async Object.onRender (file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:76312:36)
    at async renderFileInternal (file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:76289:17)
    at async renderFiles (file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:76084:17)
    at async render (file:///C:/Users/TSYPLE~1/AppData/Local/Programs/Quarto/bin/quarto.js:81071:21)

Your environment

R version 4.3.1 (2023-06-16 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8

time zone: Pacific/Auckland tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] digest_0.6.33 utf8_1.2.3 R6_2.5.1 fastmap_1.1.1
[5] tidyselect_1.2.0 magrittr_2.0.3 glue_1.6.2 tibble_3.2.1
[9] htmltools_0.5.6 pkgconfig_2.0.3 gt_0.10.0 dplyr_1.1.3
[13] generics_0.1.3 lifecycle_1.0.3 xml2_1.3.5 cli_3.6.1
[17] fansi_1.0.4 vctrs_0.6.3 compiler_4.3.1 rstudioapi_0.15.0 [21] tools_4.3.1 pillar_1.9.0 rlang_1.1.1


### Quarto check output

```bash
Quarto 1.4.415
[>] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.8: OK
      Dart Sass version 1.55.0: OK
      Deno version 1.33.4: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
      Version: 1.4.415
      Path: C:\Users\%username%\AppData\Local\Programs\Quarto\bin
      CodePage: 1252

[>] Checking tools....................OK
      TinyTeX: (external install)
      Chromium: (not installed)

[>] Checking LaTeX....................OK
      Using: TinyTex
      Path: C:\Users\%username%\AppData\Roaming\TinyTeX\bin\windows\
      Version: 2023

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

[>] Checking Python 3 installation....OK
      Version: 3.9.5 (Conda)
      Path: C:/Users/%username%/Miniconda3/python.exe
      Jupyter: 5.3.0
      Kernels: python3

[>] Checking Jupyter engine render....OK

[>] Checking R installation...........OK
      Version: 4.3.1
      Path: C:/PROGRA~1/R/R-43~1.1
      LibPaths:
        - C:/Users/%username%/AppData/Local/R/win-library/4.3
        - C:/Program Files/R/R-4.3.1/library
      knitr: 1.44
      rmarkdown: 2.25

[>] Checking Knitr engine render......OK
cderv commented 11 months ago

I believe you are trying to use a Jupyter Notebook only feature: https://quarto.org/docs/authoring/notebook-embed.html

So it won't work with engine: knitr. @dragonstyle as it change ? Otherwise we could maybe try to stop early when we detect engine knitr and embed shortcode usage ?

atsyplenkov commented 11 months ago

I believe you are trying to use a Jupyter Notebook only feature: https://quarto.org/docs/authoring/notebook-embed.html

So it won't work with engine: knitr. @dragonstyle as it change ? Otherwise we could maybe try to stop early when we detect engine knitr and embed shortcode usage ?

Thanks for the prompt response! I don't understand how than it works in manuscript projects. For example see — https://mine.quarto.pub/manuscripts-conf23/#/embedded-computations

Roughly speaking, the only difference between slides and mine reprex is that the project type wasn't specified. Could that be the reason?

cderv commented 11 months ago

Oh yes new manuscript format and features. Sorry - I missed that. 🤦 Thanks for additional content !

Recent work have support for .qmd embedding indeed using intermediary files. I see there was a bug with fig- at some point (https://github.com/quarto-dev/quarto-cli/issues/6959) so maybe there is one with tbl-.

@dragonstyle will known more.

atsyplenkov commented 10 months ago

Recent work have support for .qmd embedding indeed using intermediary files. I see there was a bug with fig- at some point (#6959) so maybe there is one with tbl-.

Sure it is! tbl-cap was the reason for the strange behavior. Moreover, it fully depends on the project type. For example, switching the project to the manuscript type will not throw an error, but it will not render tables (example 1). Removing tbl-cap in the manuscript type will result in rendering only the knitr::kable table (example 2). Removing the project type, i.e., reproducing my initial issue without tbl-cap options, will render only the kable table expanded to the full width (example 3). Note that the gt table failed to embed but did not throw any error, while the kable table embedded successfully but without the Table 3 heading!

It turns out that only knitr::kable tables could be embed, while kableExtra, gt and hux are not.

Example 1

original issue switched to manuscript type with tbl-cap

image

Example 2

original issue switched to manuscript type without tbl-cap

image

Example 3

original issue without tbl-cap options

image

dragonstyle commented 10 months ago

Thanks for the additional details - I am tracking down the issues and think I know how to fix... will update here soon...

dragonstyle commented 8 months ago

This is resolved in the current Quarto pre-release.

DOH-FAA3303 commented 6 months ago

@dragonstyle I'm still unable to render gt tables using a manuscript project type using quarto version 1.5.22 or 1.4.358. are there plans to add gt and other tables for manuscripts in the future? Or are there ways around this problem you know of?

mcanouil commented 6 months ago

@DOH-FAA3303 please provide a reproducible example as plain text or a Git repository. We can't work with "it does not work for me".

I suggest you open a new issue (possibly linking this one) with a reproducible example and all information requested in the template. Thank you for your cooperation and bug report.

DOH-FAA3303 commented 6 months ago

Recent work have support for .qmd embedding indeed using intermediary files. I see there was a bug with fig- at some point (#6959) so maybe there is one with tbl-.

Sure it is! tbl-cap was the reason for the strange behavior. Moreover, it fully depends on the project type. For example, switching the project to the manuscript type will not throw an error, but it will not render tables (example 1). Removing tbl-cap in the manuscript type will result in rendering only the knitr::kable table (example 2). Removing the project type, i.e., reproducing my initial issue without tbl-cap options, will render only the kable table expanded to the full width (example 3). Note that the gt table failed to embed but did not throw any error, while the kable table embedded successfully but without the Table 3 heading!

It turns out that only knitr::kable tables could be embed, while kableExtra, gt and hux are not.

Example 1

original issue switched to manuscript type with tbl-cap

image

Example 2

original issue switched to manuscript type without tbl-cap

image

Example 3

original issue without tbl-cap options

image

@mcanouil I meant i reproduced this example exactly and was unable to render the gt table. I will make a new issue

mcanouil commented 6 months ago

Thanks for the clarification.

mcanouil commented 6 months ago

Unfortunately, using screenshots is really a pain. @DOH-FAA3303 since you tried somehow the examples, would you mind sharing a Git repository which could be use to reproduce the issue (and possibly reopen the GitHub issue)?

DOH-FAA3303 commented 6 months ago

Unfortunately, using screenshots is really a pain. @DOH-FAA3303 since you tried somehow the examples, would you mind sharing a Git repository which could be use to reproduce the issue (and possibly reopen the GitHub issue)?

I just submitted a new issue with the example in markdown @mcanouil