Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/format/pdf/format-pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,10 @@ const longtableBottomCaptionProcessor = () => {
caption = line;
capturing = true;
return undefined;
} else if (line.match(/^\\endlastfoot/) && caption) {
line = `\\tabularnewline\n${caption}\n${line}`;
caption = undefined;
return line;
} else if (line.match(/^\\end{longtable}$/)) {
scanning = false;
if (caption) {
Expand Down
67 changes: 0 additions & 67 deletions tests/docs/latex-output/table-captions.qmd

This file was deleted.

104 changes: 104 additions & 0 deletions tests/docs/smoke-all/latex/table-captions-bottom.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
title: Document With a Variety of Table Captions
subtitle: Designed to exercise any special logic or processing of table captions
tbl-cap-location: bottom
format: pdf
keep-tex: true
_quarto:
tests:
pdf:
noErrors: default
ensureLatexFileRegexMatches:
-
# Document should not be broken
- '\\end\{document\}'
# Any table with T1 - T6 caption
- '\\begin\{longtable\}[\s\S]+\\caption\{T([1-6]|8)[\s\S]+\\endlastfoot'
# Special table with endlastfoot
- '\\begin\{longtable\}[\s\S]+\\caption\{.*T7[^}]+\}[\s\S]+\\tabularnewline\s+\\end\{longtable\}'
-
# checking caption is moved
- '\\begin\{longtable\}.*\s+\\caption\{.*T7[^}]+\}'
# checking that all caption are correctly not place after endlastfoot (using +? is important in regex)
- '\\begin\{longtable\}[\s\S]+?\\endlastfoot[\s\S]+?\\caption\{T1'
- '\\caption\{T1[\s\S]+?\\begin\{longtable\}[\s\S]+?\\endlastfoot[\s\S]+?\\caption\{T2'
- '\\caption\{T2[\s\S]+?\\begin\{longtable\}[\s\S]+?\\endlastfoot[\s\S]+?\\caption\{T3'
- '\\caption\{T3[\s\S]+?\\begin\{longtable\}[\s\S]+?\\endlastfoot[\s\S]+?\\caption\{T4'
- '\\caption\{T4[\s\S]+?\\begin\{longtable\}[\s\S]+?\\endlastfoot[\s\S]+?\\caption\{T5'
- '\\caption\{T5[\s\S]+?\\begin\{longtable\}[\s\S]+?\\endlastfoot[\s\S]+?\\caption\{T6'
- '\\caption\{T7[\s\S]+?\\begin\{longtable\}[\s\S]+?\\endlastfoot[\s\S]+?\\caption\{T8'
---


## Markdown tables


| Default | Left | Right | Center |
|---------|:-----|------:|:------:|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |

: T1 Demonstration of pipe table syntax


| Default | Left | Right | Center |
|---------|:-----|------:|:------:|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |

: T2 Demonstration of pipe table syntax that is very long and will probably wrap in the LaTeX output.

| Default | Left | Right | Center |
|---------|:-----|------:|:------:|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |

: T3 Demonstration of pipe table syntax that is very long and will probably wrap in the LaTeX output. As a result this could cause issues when we try to read the caption.


| Col1 | Col2 | Col3 |
|------|------|------|
| A | B | C |
| E | F | G |
| A | G | G |

: T4 Demonstration of pipe table syntax that is very long and will probably wrap in the LaTeX output. As a result this could cause issues when we try to read the caption. {#tbl-letters}

See @tbl-letters.


```{r}
#| tbl-cap: "T5 Demonstration of pipe table syntax that is very long and will probably wrap in the LaTeX output."
#| tbl-colwidths: [60,40]
library(knitr)
kable(head(cars))
```


```{r}
#| tbl-cap: "T6 Demonstration of pipe table syntax that is very long and will probably wrap in the LaTeX output. As a result this could cause issues when we try to read the caption."
#| tbl-colwidths: [60,40]

kable(head(cars))
```

```{r}
#| label: tbl-cars
kable(head(cars), format = "latex", longtable = TRUE, caption = "T7 HELLO CARS")
```

::: {#tbl-1}

| X | Y |
|---------|:-----|
| 12 | 12 |
| 123 | 123 |
| 1 | 1 |

T8 Table caption
:::

See @tbl-1
3 changes: 3 additions & 0 deletions tests/new-smoke-all-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ _quarto:
noErrors: default
fileExists:
supportPath: mediabag/lter_penguins.png
ensureLatexFileRegexMatches:
- []
- []
typst:
ensureFileRegexMatches:
- []
Expand Down
3 changes: 3 additions & 0 deletions tests/new-smoke-all-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ _quarto:
noErrors: default
fileExists:
supportPath: mediabag/lter_penguins.png
ensureLatexFileRegexMatches:
- []
- []
typst:
ensureFileRegexMatches:
- []
Expand Down
15 changes: 0 additions & 15 deletions tests/smoke/render/render-latex-output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,3 @@ renderVerifyLatexOutput(docs("latex-output/figure-div.qmd"), [
/\\caption{\\label{fig-foo}This is the figure}/,
/See Figure~\\ref{fig-foo} for more\./,
]);

// FIXME before merging:
//
// I don't understand how this test works even in 1.3
//
// All captions should be placed at the bottom
// Note that the 'D' or '\\' are present after the caption command because one of the
// test tables purposely msisses the caption handling to be sure that we don't
// completely destory the document. Be sure that any test document captions that must be
// moved started with D or have a label.
renderVerifyLatexOutput(docs("latex-output/table-captions.qmd"), [
/\\end{document}/,
], [
/\\begin{longtable}.*\s\\caption{[D\\]/,
]);
2 changes: 1 addition & 1 deletion tests/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ export const ensureTypstFileRegexMatches = (
return(verifyKeepFileRegexMatches("pdf", "typ")(file, matchesUntyped, noMatchesUntyped));
};

// FIXME: do this properly without resorting on file having keep-typ
// FIXME: do this properly without resorting on file having keep-tex
export const ensureLatexFileRegexMatches = (
file: string,
matchesUntyped: (string | RegExp)[],
Expand Down
Loading