quarto-dev / quarto-cli

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

Support `output-location: column` in HTML documents #3550

Open dragonstyle opened 1 year ago

dragonstyle commented 1 year ago

Discussed in https://github.com/quarto-dev/quarto-cli/discussions/3151

Originally posted by **maxdrohde** November 2, 2022 In the `reveal.js` format, we can use the `output-location: column` YAML option to show the output in the column next to the code, instead of the standard location below the code (see: https://quarto.org/docs/presentations/revealjs/#output-location) It seems to me like this is only possible in the `reveal.js` format. It would be great to have this supported in HTML documents as well.
arvindvenkatadri commented 1 month ago

Hello there, Based on Yihui Xie's webpage on chunk options, I was able to get code chunk and figure side by side in Quarto HTML using code as follows:

:::: {.columns}

:::{.column}
```{r}
#| label: plot1
#| eval: false
library(tidyverse)
library(ggformula)
library(palmerpenguins)
# Set graph theme
theme_set(new = theme_classic())

penguins %>% 
  gf_point(body_mass_g ~ flipper_length_mm,
           colour = ~ species,
           title = "Penguins Scatter Plot")

:::

:::{.column}

#| ref.label: "plot1"
#| echo: false

:::

::::


Working nicely for me! Give it a try!!
mcanouil commented 1 month ago

@arvindvenkatadri Could you properly format your post using code blocks for code and terminal outputs? Thanks. If your code contains code blocks, you need to enclose it using more backticks, i.e., usually four ````. See https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us.

Note that this issue is not about "how to have things side by side?" But really about supporting an option without requiring any other markup to get the results.

arvindvenkatadri commented 1 month ago

@mcanouil I have reformatted my comment.

I did think, and still think, that the outcome desired by @dragonstyle is to have a code chunk and its output graph side by side, as with revealjs, and what I have posted does exactly that for an HTML document. Yes, it does require more markup as you observe, but since that feature is slated for the future, this is a good solution for now, no? I am quite the newbie at Quarto so I could be wrong!

mcanouil commented 1 month ago

@arvindvenkatadri As I said, using column fenced div or layout is documented (e.g., https://quarto.org/docs/presentations/index.html#multiple-columns). This issue is really about extending the YAML option for code cell. There are various alternatives such as https://github.com/quarto-dev/quarto-cli/discussions/9646