quarto-dev / quarto-cli

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

Rendering citation in flextable to Word document #10582

Open afolson-NOAA opened 3 weeks ago

afolson-NOAA commented 3 weeks ago

Bug description

When rendering a citation in a flextable cell to a Word document, the citation formats, but the hypertext linkage to the reference is not included. The hand icon appears when the ctrl button is pushed and hovered over blue text in the citation, but no linkage. The citation and linkage works fine in text.

Steps to reproduce

---
title: "Flextable Rendering in Word"
format:
  docx:
    number-figures: true
    number-tables: true
    number-sections: true
    toc: false

execute:
  echo: false

bibliography: flextable_render_example.bib
link-citations: true
---

```{r setup}
#| warning: false

library(flextable)
library(ftExtra)
library(tidyr)
library(dplyr)

knitr::opts_chunk$set(cache = TRUE)

As shown in @tbl-chum-lh-param by @Tynan1997.

#| label: tbl-chum-lh-param
#| tbl-cap: "Summer chum salmon life cycle model parameters"

tb <- tibble(
  Parameter = "Average number of natural spawners",
  `Value(s)` = "2,343.6",
  Source = "@Tynan1997",
  Comment = "Years 2017 - 2021"
) 

  ft <- flextable(tb) |> 
  fontsize(size = 9, part = "all") |>
  width(
    j = c(1:4),
    width = c(2.0, 1.5, 1.5, 1.5)
  ) |> 
  bold(part="header") |> 
  align(align="center", part = "header") |> 
    colformat_md("Source")

  ft

References

::: {#refs} :::



[flextable_render_example.bib.txt](https://github.com/user-attachments/files/16698800/flextable_render_example.bib.txt)
[flextable_example.docx](https://github.com/user-attachments/files/16698909/flextable_example.docx)

### Expected behavior

The citation should be rendered just like in text and be hyperlinked to the references.

### Actual behavior

The citation renders, but there is no hyperlink.

### Your environment

RStudio 2023.12.1 Build 402

Windows 10 Enterprise

### Quarto check output

$ quarto check
Quarto 1.4.551
[>] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.11: OK
      Dart Sass version 1.69.5: OK
      Deno version 1.37.2: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
      Version: 1.4.551
      Path: C:\Program Files\Quarto\bin
      CodePage: 1252

[>] Checking tools....................OK
      TinyTeX: (external install)
      Chromium: (not installed)

(|) Checking LaTeX....................
(/) Checking LaTeX....................
(-) Checking LaTeX....................
(\) Checking LaTeX....................
(|) Checking LaTeX....................
(/) Checking LaTeX....................
[>] Checking LaTeX....................OK
      Using: TinyTex
      Path: C:\Users\alan.olson\AppData\Roaming\TinyTeX\bin\windows\
      Version: 2023

(|) Checking basic markdown render....
(/) Checking basic markdown render....
(-) Checking basic markdown render....
(\) Checking basic markdown render....
(|) Checking basic markdown render....
(/) Checking basic markdown render....
[>] Checking basic markdown render....OK

(|) Checking Python 3 installation....
(/) Checking Python 3 installation....
[>] Checking Python 3 installation....OK
      Version: 3.12.1
      Path: C:/Users/alan.olson/AppData/Local/Programs/Python/Python312/python.exe
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with py -m pip install jupyter

(|) Checking R installation...........
(/) Checking R installation...........
(-) Checking R installation...........
[>] Checking R installation...........OK
      Version: 4.3.2
      Path: C:/PROGRA~1/R/R-43~1.2
      LibPaths:
        - C:/Users/alan.olson/AppData/Local/R/win-library/4.3
        - C:/Program Files/R/R-4.3.2/library
      knitr: 1.48
      rmarkdown: 2.28

(|) Checking Knitr engine render......
(/) Checking Knitr engine render......
(-) Checking Knitr engine render......
(\) Checking Knitr engine render......
(|) Checking Knitr engine render......
(/) Checking Knitr engine render......
(-) Checking Knitr engine render......
(\) Checking Knitr engine render......
(|) Checking Knitr engine render......
(/) Checking Knitr engine render......
(-) Checking Knitr engine render......
(\) Checking Knitr engine render......
(|) Checking Knitr engine render......
(/) Checking Knitr engine render......
[>] Checking Knitr engine render......OK
mcanouil commented 3 weeks ago

Could you properly format your post using code blocks for code and terminal outputs? Thanks. If your code contains code blocks, you need to enclose it using more backticks, i.e., usually four ````. See https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us.

Additionally, could you make your example simple and small? i.e., do we really need all those R packages?

Finally, be aware that the current stable version is 1.5.56 and that you are using an old version.