huxtable icon indicating copy to clipboard operation
huxtable copied to clipboard

Duplicated caption when converting to Word

Open pavelaegorov opened this issue 2 years ago • 14 comments

As the output of the example code below, the Word shows duplicated caption for the generated table.

Example

library(huxtable)

jams <- hux( Type = c("Strawberry", "Raspberry", "Plum"), Price = c(1.90, 2.10, 1.80) )

library(dplyr)

jams %>% set_all_padding(4) %>% set_outer_padding(0) %>% set_number_format(2) %>% set_bold(row = c(1), col = everywhere) %>% set_bottom_border(row = 1, col = everywhere) %>% set_width(0.4) %>% set_caption("Pots of jam for sale") -> jams

quick_docx(jams, file = "jams.docx", borders = 0.4, open = interactive() )

pavelaegorov avatar Jun 17 '22 20:06 pavelaegorov

Thank you. Can reproduce.

hughjonesd avatar Jun 17 '22 21:06 hughjonesd

Could you see if it's fixed in master, using remotes::install_github("hughjonesd/huxtable")?

hughjonesd avatar Jun 17 '22 21:06 hughjonesd

remotes::install_github("hughjonesd/huxtable")

Sorry, doesn't work

pavelaegorov avatar Jun 18 '22 06:06 pavelaegorov

You mean the install command doesn't work? Or the bug is still present?

hughjonesd avatar Jun 18 '22 08:06 hughjonesd

I mean the bug is still there

From: David Hugh-Jones @.> Date: Saturday, 18 June 2022, 11:04 To: hughjonesd/huxtable @.> Cc: pavelaegorov @.>, Author @.> Subject: Re: [hughjonesd/huxtable] Duplicated caption when converting to Word (Issue #227)

You mean the install command doesn't work? Or the bug is still present?

— Reply to this email directly, view it on GitHubhttps://github.com/hughjonesd/huxtable/issues/227#issuecomment-1159392292, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZV3MJH37SQJOVC7TAW2DNLVPV7IFANCNFSM5ZDLWEZQ. You are receiving this because you authored the thread.Message ID: @.***>

pavelaegorov avatar Jun 18 '22 10:06 pavelaegorov

OK. Please could you confirm your flextable package version? Thanks.

hughjonesd avatar Jun 18 '22 11:06 hughjonesd

packageVersion("huxtable") [1] ‘5.5.0.9000’

From: David Hugh-Jones @.> Date: Saturday, 18 June 2022, 14:13 To: hughjonesd/huxtable @.> Cc: pavelaegorov @.>, Author @.> Subject: Re: [hughjonesd/huxtable] Duplicated caption when converting to Word (Issue #227)

OK. Please could you confirm your flextable package version? Thanks.

— Reply to this email directly, view it on GitHubhttps://github.com/hughjonesd/huxtable/issues/227#issuecomment-1159446269, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZV3MJAMXC4M4YRE5ZX3Z53VPWVN3ANCNFSM5ZDLWEZQ. You are receiving this because you authored the thread.Message ID: @.***>

pavelaegorov avatar Jun 18 '22 12:06 pavelaegorov

Right, but what is your flextable package version?

hughjonesd avatar Jun 18 '22 13:06 hughjonesd

packageVersion("huxtable") [1] ‘5.5.0.9000’ packageVersion("flextable") [1] ‘0.7.2’

From: David Hugh-Jones @.> Date: Saturday, 18 June 2022, 16:19 To: hughjonesd/huxtable @.> Cc: pavelaegorov @.>, Author @.> Subject: Re: [hughjonesd/huxtable] Duplicated caption when converting to Word (Issue #227)

Right, but what is your flextable package version?

— Reply to this email directly, view it on GitHubhttps://github.com/hughjonesd/huxtable/issues/227#issuecomment-1159464117, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZV3MJAULWJJDGALNSOVWQTVPXEHDANCNFSM5ZDLWEZQ. You are receiving this because you authored the thread.Message ID: @.***>

pavelaegorov avatar Jun 18 '22 13:06 pavelaegorov

Mm. OK, now I can't reproduce. With current github and flextable 0.7.2, your code just gives me a single caption.

hughjonesd avatar Jun 18 '22 13:06 hughjonesd

Could I maybe check the officer version?

hughjonesd avatar Jun 18 '22 14:06 hughjonesd

Lucky you are! Maybe something wrong from my side) By the way, thanks a LOT!! For your package, just calculated some clinical trial results and it was very easy to send tables to word with the huxtable!! Great job

Pavel

packageVersion("huxtable") [1] ‘5.5.0.9000’ packageVersion("flextable") [1] ‘0.7.2’ packageVersion("officer") [1] ‘0.4.3’

From: David Hugh-Jones @.> Date: Saturday, 18 June 2022, 17:40 To: hughjonesd/huxtable @.> Cc: pavelaegorov @.>, Author @.> Subject: Re: [hughjonesd/huxtable] Duplicated caption when converting to Word (Issue #227)

Could I maybe check the officer version?

— Reply to this email directly, view it on GitHubhttps://github.com/hughjonesd/huxtable/issues/227#issuecomment-1159476352, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZV3MJHKSXWUZZPZ5F4OHADVPXNWXANCNFSM5ZDLWEZQ. You are receiving this because you authored the thread.Message ID: @.***>

pavelaegorov avatar Jun 18 '22 16:06 pavelaegorov

Glad to hear it!

This is hard to debug, obviously. If you could try debugonce(quick_docx) and maybe debugonce(huxtable:::as_flextable.huxtable) and see what is going on, that might give some insight - in particular, do you see multiple calls to set_caption()? See ?debug and ?browser if you're not familiar with using the debugger.

hughjonesd avatar Jun 18 '22 18:06 hughjonesd

If possible, could you check whether you get the double caption when you evaluate a huxtable with a caption in an rmarkdown Word document?

hughjonesd avatar Jun 22 '22 06:06 hughjonesd

Closing until I hear anything back. My guess is that this might be due to confusing huxtable::set_caption() with flextable::set_caption().

hughjonesd avatar Oct 11 '23 10:10 hughjonesd