quarto-dev / quarto-cli

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

Table caption located at bottom when you have subtables in docx format #1990

Open dmkaplan2000 opened 2 years ago

dmkaplan2000 commented 2 years ago

Bug description

When using docx format and generating a table with multiple sub-tables, the overall caption of the tables appears at the bottom of the table instead of the top. For example, compare the two tables in this document:

---
title: "Bad caption placement"
format: docx
---

# Single table with caption on top

```{r}
#| label: tbl-one
#| tbl-cap: "Caption on top"
library(knitr)
kable(head(cars))

Sub-tables with overall caption on bottom

#| label: tbl-two
#| tbl-cap-location: top
#| tbl-cap: "Caption on bottom"
#| tbl-subcap: 
#|   - "Cars"
#|   - "Pressure"
library(knitr)
kable(head(cars))
kable(head(pressure))

The second table has the overall caption at the bottom. This behavior is inconsistent with other output formats (both `html` and `pdf` place the overall caption at the top) and does not appear to be controllable with `tbl-cap-location`.

### `quarto check` Output

```bash
[✓] Checking Quarto installation......OK
      Version: 1.0.38
      Path: /opt/quarto/bin

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.8.10
      Path: /usr/bin/python3
      Jupyter: 4.11.1
      Kernels: python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.2.1
      Path: /usr/lib/R
      LibPaths:
        - /home/dmk/R/x86_64-pc-linux-gnu-library/4.2
        - /usr/local/lib/R/site-library
        - /usr/lib/R/site-library
        - /usr/lib/R/library
      rmarkdown: 2.14

[✓] Checking Knitr engine render......OK

quarto tools check Output

[✓] Inspecting tools

Tool         Status            Installed     Latest  
chromium     Not installed     ---           869685  
tinytex      Not installed     ---           v2022.08

Checklist

jjallaire commented 2 years ago

Thanks for pointing this out! This is indeed a hole in our table caption processing (it is correct that tbl-cap-location doesn't currently work for Word but nevertheless we should still be placing the overall caption above as you suggest.

dmkaplan2000 commented 2 years ago

Thanks. Presumably there are plans for tbl-cap-location to work for Word documents in the future?

jjallaire commented 2 years ago

Yes we will certainly try!

cscheid commented 1 year ago

(cc @rich-iannone)

rich-iannone commented 1 year ago

Will take a look at this to see if anything could be done for v1.3.

cscheid commented 1 year ago

This is unfortunately blocked because of crossref interactions. We will do crossref work on 1.4 and that will unblock this issue.

cscheid commented 1 year ago

We have a partial fix incoming in #7449 for caption location in word. But we don't yet have subcaption location control anywhere. I'll try to land that in 1.4.