davidgohel / flextable

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

Crossref in table caption not being resolved when using Quarto #592

Closed cschwarz-stat-sfu-ca closed 7 months ago

cschwarz-stat-sfu-ca commented 10 months ago

I can use @tbl-tablename or @fig-figname in a figure caption and they are resolved properly. However, if I try and crossreference in a table caption, it is not resolved.

MWE and output attached

Thanks. Carl Schwarz


title: "test" author: "Carl James Schwarz" date: today date-format: "YYYY-MM-DD" execute: error: true format: html: toc: true number-sections: true self-contained: true pdf: toc: true number-sections: true fig-pos: ht docx: toc: true number-sections: true format-links: false fig-cap-location: top

Cross references in tables and figures

This is a standard xref to @tbl-map-unit-strata which works fine.

#| echo: false
#| warning: false
#| message: false

library(ggplot2)

map.unit.stratum.csv <- textConnection(
"Sample..Map.Unit, Stratum
19, L
18, M
17, L
")
map.unit.stratum <- read.csv(map.unit.stratum.csv, header=TRUE, as.is=TRUE, strip.white=TRUE)
#| echo: false
#| warning: false
#| message: false
#| tbl-cap: "Map unit strata"
#| label: tbl-map-unit-strata

ft <- flextable::flextable(map.unit.stratum)
ft

We can reference the table in a caption for a figure as shown below

#| echo: false
#| warning: false
#| message: false
#| fig-cap: Reference to @tbl-map-unit-strata in a figure caption works fine.
#| label: figl-map-unit-strata

df <- data.frame(x=1:10, y=1:10)
ggplot(data=df, aes(x=x, y=y))+
   geom_point()

The following doesn't seem to work since the cross reference is not resolved in the captions.

#| echo: false
#| warning: false
#| message: false
#| tbl-cap: Map unit strata 2 wich references  @tbl-map-unit-strata
#| label: tbl-map-unit-strata2

ft <- flextable::flextable(map.unit.stratum[1:5,])
ft
#| echo: false
#| warning: false
#| message: false

sessionInfo()

test.pdf

davidgohel commented 10 months ago

Thanks,

Quarto is managing captions on its own. We can't do anything about the way it manages them. As you can see here https://github.com/davidgohel/flextable/blob/master/R/printers.R#L350 and here https://github.com/davidgohel/flextable/blob/master/R/latex_str.R#L219, there is no code in flextable that manage captions for quarto!

I think quarto team made improvements with the latest versions of quarto. I have no idea what version of quarto you are using but I recommend updating it regularly as it is in active development.

cschwarz-stat-sfu-ca commented 10 months ago

Thanks for your quick reply... I'm running the current release of quarto... I'll submit this issue to quarto. Thanks.

Carl.

On Fri, Nov 24, 2023 at 10:46 AM David Gohel @.***> wrote:

Thanks,

Quarto is managing captions on its own. We can't do anything about the way it manages them. As you can see here https://github.com/davidgohel/flextable/blob/master/R/printers.R#L350 and here https://github.com/davidgohel/flextable/blob/master/R/latex_str.R#L219, there is no code in flextable that manage captions for quarto!

I think quarto team made improvements with the latest versions of quarto. I have no idea what version of quarto you are using but I recommend updating it regularly as it is in active development.

— Reply to this email directly, view it on GitHub https://github.com/davidgohel/flextable/issues/592#issuecomment-1825993957, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXIXRX7AZRT3CU7EVKS5TLYGDTSHAVCNFSM6AAAAAA7ZOEUT2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRVHE4TGOJVG4 . You are receiving this because you authored the thread.Message ID: @.***>

cschwarz-stat-sfu-ca commented 10 months ago

BTW, it is possible to include a crossref in a footnote? If you have @ref in a string it is not resolved. There must be some settings in the as_paragraph() that would allow it to be resolved? Thanks Carl

On Fri, Nov 24, 2023 at 11:07 AM Carl Schwarz @.***> wrote:

Thanks for your quick reply... I'm running the current release of quarto... I'll submit this issue to quarto. Thanks.

Carl.

On Fri, Nov 24, 2023 at 10:46 AM David Gohel @.***> wrote:

Thanks,

Quarto is managing captions on its own. We can't do anything about the way it manages them. As you can see here https://github.com/davidgohel/flextable/blob/master/R/printers.R#L350 and here https://github.com/davidgohel/flextable/blob/master/R/latex_str.R#L219, there is no code in flextable that manage captions for quarto!

I think quarto team made improvements with the latest versions of quarto. I have no idea what version of quarto you are using but I recommend updating it regularly as it is in active development.

— Reply to this email directly, view it on GitHub https://github.com/davidgohel/flextable/issues/592#issuecomment-1825993957, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXIXRX7AZRT3CU7EVKS5TLYGDTSHAVCNFSM6AAAAAA7ZOEUT2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRVHE4TGOJVG4 . You are receiving this because you authored the thread.Message ID: @.***>

cschwarz-stat-sfu-ca commented 10 months ago

BTW again... this issue of xref in table captions seems to be fixed in the development version (pre-release) version of quarto...Next trying to figure out crossref in footnotes. Carl

On Fri, Nov 24, 2023 at 2:17 PM Carl Schwarz @.***> wrote:

BTW, it is possible to include a crossref in a footnote? If you have @ref in a string it is not resolved. There must be some settings in the as_paragraph() that would allow it to be resolved? Thanks Carl

On Fri, Nov 24, 2023 at 11:07 AM Carl Schwarz @.***> wrote:

Thanks for your quick reply... I'm running the current release of quarto... I'll submit this issue to quarto. Thanks.

Carl.

On Fri, Nov 24, 2023 at 10:46 AM David Gohel @.***> wrote:

Thanks,

Quarto is managing captions on its own. We can't do anything about the way it manages them. As you can see here https://github.com/davidgohel/flextable/blob/master/R/printers.R#L350 and here https://github.com/davidgohel/flextable/blob/master/R/latex_str.R#L219, there is no code in flextable that manage captions for quarto!

I think quarto team made improvements with the latest versions of quarto. I have no idea what version of quarto you are using but I recommend updating it regularly as it is in active development.

— Reply to this email directly, view it on GitHub https://github.com/davidgohel/flextable/issues/592#issuecomment-1825993957, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXIXRX7AZRT3CU7EVKS5TLYGDTSHAVCNFSM6AAAAAA7ZOEUT2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRVHE4TGOJVG4 . You are receiving this because you authored the thread.Message ID: @.***>

davidgohel commented 7 months ago

thank you

this issue of xref in table captions seems to be fixed

Yes, I can see that with Quarto 1.4.549

it is possible to include a crossref in a footnote?

No sorry, Quarto doesn't scan content that isn't markdown and flextable provides latex, Word or HTML code and not markdown.

github-actions[bot] commented 4 weeks 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.