hughjonesd / huxtable

An R package to create styled tables in multiple output formats, with a friendly, modern interface.
http://hughjonesd.github.io/huxtable
Other
322 stars 28 forks source link

Quarto Table Reference Workaround Not Working in Quarto 1.5 #254

Closed reuning closed 5 months ago

reuning commented 5 months ago

Describe the bug

The workaround to referencing tables in Quarto does not seem to work with Quarto 1.5 (the current release candidate). It appears that Quarto just swallows the \label() in its entirety. I installed Quarto 1.4 and the workaround still works in that case. I wasn't sure if I should post this as a reply to https://github.com/hughjonesd/huxtable/issues/224 or not so hopefully this is alright.

I tried a few different combinations to get it to work including adding \\label{} into the set_caption() but nothing seemed to get it to work. I'll just switch back to Quarto 1.4 for now.

Minimal Reproducible Example

---
title: Test
format: 
    pdf:
        keep-tex: true
---

A reference to Table \ref{tab:jams}.

```{r}
library(huxtable)
label(jams) <- "tab:jams"
caption(jams) <- "Some jams"
jams

The relevant tex file generated from Quarto 1.5.41:

\begin{table}[ht] \begin{centerbox} \begin{threeparttable} \captionsetup{justification=centering,singlelinecheck=off} \caption{Some jams}

\setlength{\tabcolsep}{0pt} \begin{tabular}{l l}


The relevant tex file generated from Quarto 1.4.555:

\begin{table}[ht] \begin{centerbox} \begin{threeparttable} \captionsetup{justification=centering,singlelinecheck=off} \caption{Some jams} \label{tab:jams} \setlength{\tabcolsep}{0pt} \begin{tabular}{l l}


**System details**

R.version _
platform aarch64-apple-darwin20
arch aarch64
os darwin20
system aarch64, darwin20
status
major 4
minor 3.2
year 2023
month 10
day 31
svn rev 85441
language R
version.string R version 4.3.2 (2023-10-31) nickname Eye Holes
packageVersion("huxtable") [1] ‘5.5.6’

hughjonesd commented 5 months ago

Thanks for the report.

hughjonesd commented 5 months ago

See also https://github.com/quarto-dev/quarto-cli/issues/8564#issuecomment-2176800308. This is probably a bug in quarto-cli, I think their goal is not to eat labels unless they contain a hyphen. So it may get fixed. If not, there may indeed be no way to use labels with TeX tables in quarto.

reuning commented 5 months ago

Thanks for the quick response. Hopefully they are able to fix this in the Quarto CLI.

hughjonesd commented 5 months ago

could you try github master and see if it indeed fixes this problem?

reuning commented 5 months ago

Sorry for the slow reply here, I wanted to get back to my Mac in my office to try and was away from the office for a few days.

It does work now, though with the caveat that I had to install the quarto R package. Based on your comment you already knew this was a risk. I use VS Code and installed quarto directly. It might be worth noting this somewhere in the FAQ.

reuning commented 5 months ago

One other thing, I'm not sure if it is on purpose or not but currently you do not have quietly=TRUE in the check for the quarto package: https://github.com/hughjonesd/huxtable/blob/ca7b30a029874270e6a79bdffe04b876f86f9986/R/aaa-utils.R#L254

This was helpful for me as it flagged that I didn't have the quarto package installed and I installed it. For those not using Quarto it might be annoying. I'm not sure when this gets called though but wanted to flag it for you.

hughjonesd commented 5 months ago

Thanks for this point. Fixed in master.

reuning commented 5 months ago

FYI your "try harder to find quarto" worked for me without the Quarto R package installed. Thanks for making and maintaining huxtable and for being so quick at it all.