quarto-dev / quarto-cli

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

Multicolumns with `layout` in `pdf` output don't work when a column contains a code cell #10981

Open mine-cetinkaya-rundel opened 3 weeks ago

mine-cetinkaya-rundel commented 3 weeks ago

Quarto 1.6.12.

Here is a reprex:

---
format: pdf
fig-width: 3
fig-height: 1
---

<!-- This works -->
:::: {layout="[ 0.1, 0.9 ]"}
::: {#first-column}
\(a\)
:::
::: {#second-column}
Some text.
:::
::::

<!-- This also works -->
:::: {layout="[ 0.1, 0.9 ]"}
::: {#first-column}
\(b\)
:::
::: {#second-column}
```{r}
#| echo: false
par(mar = c(0, 0, 0, 0))
plot(1:10)

::: ::::

:::: {layout="[ 0.1, 0.9 ]"} ::: {#first-column} (c) ::: ::: {#second-column}

#| echo: true
par(mar = c(0, 0, 0, 0))
plot(1:10)

::: ::::

:::: {layout="[ 0.1, 0.9 ]"} ::: {#first-column} (d) ::: ::: {#second-column}

#| eval: false
#| echo: true
par(mar = c(0, 0, 0, 0))
plot(1:10)

::: ::::



When the second column contains a code cell that is `echo`ed, it spans the whole width and columns fail.

![Image](https://github.com/user-attachments/assets/f63e15d8-4f01-46d4-b5ba-67000a9ca72e)

(Note: When I render this document, `(d)` is printed on the second page. I think this is the usual LaTeX weird page break issue that is not relevant to this, so I didn't show that in the screenshot above.)
cderv commented 2 weeks ago

I believe this is related to this previous discussion where I was also puzzled by the behavior.

Basically no way to but code cells in a column layout when using layout. Only using columns div will work.

This is layout feature / limitation, to be discussed maybe more.

cderv commented 2 weeks ago

@mine-cetinkaya-rundel #8179 has been closed as the merging problem between two different language is fixed. Though what has been discussed there with @cscheid still applies.

It seems the fact we strip out the code cell from the layout column is expected behavior. I learned that from @cscheid and still found that puzzling behavior, but it inherits behavior from when layout: is used as a code cell option I believe. (https://quarto.org/docs/authoring/figures.html#custom-layout)

If we really stay with that behavior for Block Layout using Div syntax, we probably need to explain at this part of the documentation: https://quarto.org/docs/authoring/figures.html#block-layout

Problem you see if for any format by the way, not just PDF

For what you want to achieve, you need could use columns but it works only for HTML

---
format: html
fig-width: 3
fig-height: 1
---

:::: {.columns}
::: {#first-column .column width="0.1"}
\(c\)
:::
::: {#second-column .column width="0.9"}
```{r}
#| echo: true
par(mar = c(0, 0, 0, 0))
plot(1:10)

::: ::::



![Image](https://github.com/user-attachments/assets/e8da793e-800e-4f05-9698-8296fd0f3d0b)

But it does not work PDF 🤔  (maybe because as it is not really a Quarto feature like layout and it applies with CSS 🤷 need to 👀 into this)
So there is no straightforward way to achieve the same as in HTML for PDF to show code cell inside a column. 

IMO this still need to be discussed.