Skip to content

Commit a612731

Browse files
authored
Merge pull request #9973 from quarto-dev/bugfix/8656
lua,latex - don't crash on captionless tables in subfloats
2 parents c96d534 + 4139da5 commit a612731

File tree

3 files changed

+62
-7
lines changed

3 files changed

+62
-7
lines changed

news/changelog-1.5.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ All changes included in 1.5:
1818
## PDF Format
1919

2020
- ([#8299](https://github.com/quarto-dev/quarto-cli/issues/8299)): Don't use `rsvg-convert` to convert an SVG to PDF when the PDF is already available; add `use-rsvg-convert` option to control this behavior.
21+
- ([#8656](https://github.com/quarto-dev/quarto-cli/issues/8656)): Don't crash on captionless tables in subfloats.
2122
- ([#8684](https://github.com/quarto-dev/quarto-cli/issues/8684)): Improve detection and automatic installation of locale specific hyphenation files.
2223
- ([#8711](https://github.com/quarto-dev/quarto-cli/issues/8711)): Enforce rendering of tables as `tabular` environments when custom float environments are present.
2324
- ([#8841](https://github.com/quarto-dev/quarto-cli/issues/8841)): Do not parse LaTeX table when crossref label doesn't start with `tbl-`.

src/resources/filters/layout/latex.lua

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,16 @@ function latexCell(cell, vAlign, endOfRow, endOfTable)
351351
content:insert(pandoc.Para(caption))
352352
cellOutput = true
353353
elseif isFigure then
354-
local caption = refCaptionFromDiv(cell).content
355-
markupLatexCaption(cell, caption)
356-
content:insert(pandoc.RawBlock("latex", "\\raisebox{-\\height}{"))
357-
tappend(content, tslice(cell.content, 1, #cell.content-1))
358-
content:insert(pandoc.RawBlock("latex", "}"))
359-
content:insert(pandoc.Para(caption))
360-
cellOutput = true
354+
local caption_el = refCaptionFromDiv(cell)
355+
if caption_el ~= nil then
356+
local caption = caption_el.content
357+
markupLatexCaption(cell, caption)
358+
content:insert(pandoc.RawBlock("latex", "\\raisebox{-\\height}{"))
359+
tappend(content, tslice(cell.content, 1, #cell.content-1))
360+
content:insert(pandoc.RawBlock("latex", "}"))
361+
content:insert(pandoc.Para(caption))
362+
cellOutput = true
363+
end
361364
end
362365
end
363366

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: "test"
3+
format: latex
4+
---
5+
6+
:::: {#tbl-test layout-ncol="2"}
7+
8+
::: {#tbl-test1}
9+
10+
```{=html}
11+
<table>
12+
<thead>
13+
<tr>
14+
<th>test</th>
15+
<th>test</th>
16+
</tr>
17+
</thead>
18+
<tbody>
19+
<tr>
20+
<td>test</td>
21+
<td>test</td>
22+
</tr>
23+
</tbody>
24+
</table>
25+
```
26+
27+
:::
28+
29+
::: {#tbl-test2}
30+
31+
```{=html}
32+
<table>
33+
<thead>
34+
<tr>
35+
<th>test</th>
36+
<th>test</th>
37+
</tr>
38+
</thead>
39+
<tbody>
40+
<tr>
41+
<td>test</td>
42+
<td>test</td>
43+
</tr>
44+
</tbody>
45+
</table>
46+
```
47+
48+
:::
49+
50+
Test
51+
::::

0 commit comments

Comments
 (0)