davidgohel / flextable

table farming
https://ardata-fr.github.io/flextable-book/
565 stars 82 forks source link

Left aligned caption #565

Closed cwilso6 closed 9 months ago

cwilso6 commented 1 year ago

I am hoping to left aligned table caption, This issue was closed here https://github.com/davidgohel/flextable/issues/425.

I copied the code provided:

---
title: "Untitled"
format: 
  docx:
    keep-md: false
---
library(flextable)
library(officer)
knitr::opts_chunk$set(echo = FALSE)
fpp <- fp_par(text.align = "left", padding = 3)

blah blah blah r run_reference(id = "tbl-flextable-1").

#| label: tbl-flextable-1
#| tbl-cap: dummy
#| ft.align: right
ft <- flextable(mtcars[1:4, 1:4])
ft |>
  set_caption(
    caption = as_paragraph(
      "Caption ",
      as_chunk("strong", props = fp_text_default(bold = TRUE))
    ),
    align_with_table = FALSE,
    word_stylename = "Table Caption",
    fp_p = fpp
  )
#| label: tbl-flextable-2
#| tbl-cap: dummy

ft |>
  set_caption(
    caption = as_paragraph(
      "Caption ",
      as_chunk("strong", props = fp_text_default(bold = TRUE))
    ),
    align_with_table = TRUE, # default
    word_stylename = "Table Caption",
    fp_p = fpp
  )

and it produced the following: image

Notice that the captions are all on the left of the page (not the left of the table), I am getting different output than what you have shown in the previous thread.

davidgohel commented 1 year ago

Hello, this is a quarto Word document. Quarto is managing captions on its own. With flextable, it works with PDF and HTML but not Word. That's an issue we are aware of since quarto exists, we can't do anything about it.

You can read flextable documentation about it here: https://davidgohel.github.io/flextable/reference/set_caption.html#using-quarto-

davidgohel commented 9 months ago

This issue can be closed, captions seem to work as expected with Quarto 1.4.549 with Word PDF and HTML. 'flextable' does not emit any caption when used in Quarto.

For future readers, TLTR, set_caption() has not effect with Quarto that manage captions on its own.

github-actions[bot] commented 3 months ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.