Skip to content

Commit c736ea0

Browse files
authored
Add dark-mode images for figures and markdown-basics docs (#2120)
Figures and Markdown Basics currently ship light-only elephant screenshots, which look jarring against a dark background for readers using the site's dark theme. Revives #1641, dropping its vendored pandoc-ext/list-table Lua filter in favor of the native list-table syntax Quarto 1.9 shipped after that PR went stale. Also wires up layout-attrib-negative-dark.png, which the original PR added but never referenced.
1 parent 21ec13a commit c736ea0

16 files changed

Lines changed: 179 additions & 57 deletions

‎_freeze/docs/authoring/cross-references/execute-results/html.json‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
97 Bytes
Loading

‎_freeze/docs/authoring/tables/execute-results/html.json‎

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

‎docs/authoring/_table-crossrefs.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ See @tbl-letters.
1616

1717
Which looks like this when rendered to HTML:
1818

19+
::: light-content
1920
![](images/crossref-table.png){fig-alt="A table with 3 columns and four rows. The text 'Table 1: My Caption' is above the header column. The text 'See tbl. 1' is aligned to the left underneath the last column." width="500"}
21+
:::
22+
23+
::: dark-content
24+
![](images/crossref-table-dark.png){fig-alt="A table with 3 columns and four rows. The text 'Table 1: My Caption' is above the header column. The text 'See tbl. 1' is aligned to the left underneath the last column." width="500"}
25+
:::

‎docs/authoring/elephant-dark.png‎

108 KB
Loading

‎docs/authoring/figures.qmd‎

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,21 @@ In Pandoc markdown, a figure is created whenever a captioned image appears by-it
1818

1919
This results in the following treatment for various output types:
2020

21-
| HTML | PDF | Word |
22-
|---------------------------|-----------------------|-----------------------|
23-
| ![](images/html-figure.png){fig-alt="A line drawing of an elephant." width="340"} | ![](images/pdf-figure.png){fig-alt="A line drawing of an elephant."} | ![](images/word-figure.png){fig-alt="A line drawing of an elephant."} |
21+
::: {.list-table header-rows=1 tbl-colwidths="[33,33,33]"}
22+
- - HTML
23+
- PDF
24+
- Word
25+
26+
- - ::: light-content
27+
![](images/html-figure.png){fig-alt="A line drawing of an elephant." width="340"}
28+
:::
29+
30+
::: dark-content
31+
![](images/html-figure-dark.png){fig-alt="A line drawing of an elephant." width="340"}
32+
:::
33+
- ![](images/pdf-figure.png){fig-alt="A line drawing of an elephant."}
34+
- ![](images/word-figure.png){fig-alt="A line drawing of an elephant."}
35+
:::
2436

2537
Note that for LaTeX / PDF output figures are automatically numbered (you can arrange for figures to be numbered in other formats using [Cross References](cross-references.qmd)).
2638

@@ -139,9 +151,15 @@ format:
139151

140152
In HTML output formats you can add lightbox styling and behavior to images to allow a reader to click to see a larger version of the image. For example, the following image has lightbox treatment (click on the image to see lightbox in action):
141153

154+
::: light-content
142155
![An elephant](elephant.png){.lightbox width=50%}
156+
:::
157+
158+
::: dark-content
159+
![An elephant](elephant-dark.png){.lightbox width=50%}
160+
:::
143161

144-
Lightbox treatment can be added by adding the class `.lightbox` to an image:
162+
Lightbox treatment can be added by adding the class `.lightbox` to an image:
145163

146164
```markdown
147165
![An elephant](elephant.png){.lightbox}
@@ -205,7 +223,13 @@ Famous Elephants
205223

206224
Again, the last paragraph provides the main caption, and the individual figures carry the sub-captions. Here is what this looks like when rendered as HTML:
207225

226+
::: light-content
208227
![](images/elephant-subfigures.png){fig-alt="An artistic rendition of Surus, Hannibal's last war elephant, is on the left. Underneath this picture is the caption '(a) Surus.' On the right is a line drawing of Hanno, a famous elephant. Underneath this picture is the caption '(b) Hanno.' The words 'Figure 1: Famous elephants' are centered beneath both pictures."}
228+
:::
229+
230+
::: dark-content
231+
![](images/elephant-subfigures-dark.png){fig-alt="An artistic rendition of Surus, Hannibal's last war elephant, is on the left. Underneath this picture is the caption '(a) Surus.' On the right is a line drawing of Hanno, a famous elephant. Underneath this picture is the caption '(b) Hanno.' The words 'Figure 1: Famous elephants' are centered beneath both pictures."}
232+
:::
209233

210234
Note that the empty lines between the figures (and between the last figure and the caption) are required (it's what indicates that these images belong to their own paragraphs rather than being multiple images within the same paragraph).
211235

@@ -225,7 +249,13 @@ To layout two figures with their own standalone captions (and no main caption),
225249
:::
226250
```
227251

252+
::: light-content
228253
![](images/elephant-figures-no-subcaption.png){fig-alt="An artistic rendition of Surus, Hannibal's last war elephant, is on the left. Underneath this picture is the caption 'Surus.' On the right is a line drawing of Hanno, a famous elephant. Underneath this picture is the caption 'Hanno.'"}
254+
:::
255+
256+
::: dark-content
257+
![](images/elephant-figures-no-subcaption-dark.png){fig-alt="An artistic rendition of Surus, Hannibal's last war elephant, is on the left. Underneath this picture is the caption 'Surus.' On the right is a line drawing of Hanno, a famous elephant. Underneath this picture is the caption 'Hanno.'"}
258+
:::
229259

230260
You can also eliminate the captions entirely:
231261

@@ -253,7 +283,13 @@ If you have more than 2 images, you might want to lay them out across multiple r
253283
:::
254284
```
255285

286+
::: light-content
256287
![](images/elephant-rows.png){fig-alt="A 2x2 grid of pictures of elephants. There are labels underneath each of the pictures. Clockwise from the upper left, the labels say: Surus, Hanno, Lin Wang, and Abdul Abbas."}
288+
:::
289+
290+
::: dark-content
291+
![](images/elephant-rows-dark.png){fig-alt="A 2x2 grid of pictures of elephants. There are labels underneath each of the pictures. Clockwise from the upper left, the labels say: Surus, Hanno, Lin Wang, and Abdul Abbas."}
292+
:::
257293

258294
More complex figure arrangements (e.g. rows with varying column layouts) are possible. See the [Custom Layouts](#complex-layouts) section below for more details.
259295

@@ -404,7 +440,13 @@ For example, this defines a layout with two equally sized figures in the first r
404440
:::
405441
```
406442

443+
::: light-content
407444
![](images/layout-attrib.png){fig-alt="Three elephant pictures arranged such that two pictures are side-by-side in the first row, and the third picture is underneath both of these. The picture on the left in the first row is captioned 'Surus' and the picture on the right is captioned 'Hanno'. The picture underneath these two is captioned 'Lin Wang' and is as as wide and tall as the other two put together."}
445+
:::
446+
447+
::: dark-content
448+
![](images/layout-attrib-dark.png){fig-alt="Three elephant pictures arranged such that two pictures are side-by-side in the first row, and the third picture is underneath both of these. The picture on the left in the first row is captioned 'Surus' and the picture on the right is captioned 'Hanno'. The picture underneath these two is captioned 'Lin Wang' and is as as wide and tall as the other two put together."}
449+
:::
408450

409451
The `layout` attribute is a 2-dimensional array where the first dimension defines rows and the second columns. In this case `"layout="[[1,1], [1]]"` translates to: create two rows, the first of which has two columns of equal size and the second of which has a single column.
410452

@@ -432,7 +474,13 @@ You can also use negative values to create space between elements. For example:
432474
:::
433475
```
434476

477+
::: light-content
435478
![](images/layout-attrib-negative.png){fig-alt="Three elephant pictures arranged such that two pictures are side-by-side in the first row, and the third picture is underneath both of these. The picture on the left in the first row is captioned 'Surus' and the picture on the right is captioned 'Hanno'. The two pictures are separated by some whitespace. The picture underneath these two is captioned 'Lin Wang' and is wider and taller than the other two put together."}
479+
:::
480+
481+
::: dark-content
482+
![](images/layout-attrib-negative-dark.png){fig-alt="Three elephant pictures arranged such that two pictures are side-by-side in the first row, and the third picture is underneath both of these. The picture on the left in the first row is captioned 'Surus' and the picture on the right is captioned 'Hanno'. The two pictures are separated by some whitespace. The picture underneath these two is captioned 'Lin Wang' and is wider and taller than the other two put together."}
483+
:::
436484

437485
### Vertical Alignment
438486

@@ -446,7 +494,13 @@ If you have a layout with a row of images of differing heights, you can control
446494
:::
447495
```
448496

497+
::: light-content
449498
![](images/valign.png){fig-alt="Two pictures of elephants side by side. The picture on the left has the label 'Figure 1: Surus' underneath it. The picture on the right has the label 'Figure 2: Lin Wang' underneath it. The figure on the left is more than twice the width and height of the figure on the right."}
499+
:::
500+
501+
::: dark-content
502+
![](images/valign-dark.png){fig-alt="Two pictures of elephants side by side. The picture on the left has the label 'Figure 1: Surus' underneath it. The picture on the right has the label 'Figure 2: Lin Wang' underneath it. The figure on the left is more than twice the width and height of the figure on the right."}
503+
:::
450504

451505
Note that vertical alignment isn't limited to images, you can also vertically align any other elements that are included in a panel.
452506

42.2 KB
Loading
1.75 MB
Loading
3.68 MB
Loading
1.77 MB
Loading

0 commit comments

Comments
 (0)