You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support Add reference by bibtex @ in the function tab_source_note #112
I am reading the vignette and find this table add a source note with reference McNeil, D. R. (1977).
Here is related R code I copy from this vignette.
# Display the `islands_tbl` data with a heading and
# two source notes
gt_tbl <-
gt_tbl %>%
tab_source_note(
source_note = "Source: The World Almanac and Book of Facts, 1975, page 406."
) %>%
tab_source_note(
source_note = md("Reference: McNeil, D. R. (1977) *Interactive Data Analysis*. Wiley.")
)
# Show the gt Table
gt_tbl
Does the function tab_source_note to support BibTeX reference in the future?
Maybe it is hard because I don't see other packages to support this feature.
Closely related, it would be really useful for me if there was some sort of fmt_citation function, which would take a bibtex file and then format a column of @-tags ("@li2019") into a column of short ("Li (2019)") or long ("'Title of a Good Paper'. Bob Li, 2019 Journal of Cool Stuff vol. 4 no. 20" ) citation. This would be good for literature reviews, meta-analyses, tables of software used/data sources, etc.
My understand is that the reason @-tags don't work in gt is because it exports LaTex, but pandoc is skipping those tags when parsing the text with pandoc-citeproc. On the other hand knitr::kable(format="markdown") exports plain markdown tables and therefore they get properly parsed for @-tags. I don't know if anything can be done at all, since markdown formatting is very limited. Perhaps there's a solution with a different reference processor: natbib or biblatex, but I don't know enough to speak about that confidently.
use citation_package: natbib for processing references
make a dataframe of citations in LaTeX style (double-escaped).
pass to gt and use post-formatting with tools::encoded_text_to_latex()
Generally speaking, fmt(cols, fns=tools::encoded_text_to_latex) seems to be a useful pattern. Would you consider adding it as a standard formatter, i.e. fmt_latex(), @rich-iannone ? Would you like a PR with that?
UPDATE
Here's my [@ref] to \cite{ref} transforming function
Activity
[-]Support bib te x[/-][+]Support Add reference by bibtex `@` in the function `tab_source_note`[/+]rich-iannone commentedon Dec 23, 2018
Thanks for filing this issue. It seems like a very good idea to integrate citations with BibTeX. I'll look into how this can be done easily.
rich-iannone commentedon Jan 22, 2019
Looking into the possibility of adding a new method for LaTeX that could use additional arguments for different citation types.
JiaxiangBU commentedon Feb 7, 2019
I find it maybe helps to add the arguement
results='asis'in the R chunk.However, the arguement
results='asis'maybe disturbs thegtdisplay.csoeder commentedon Apr 24, 2020
Closely related, it would be really useful for me if there was some sort of fmt_citation function, which would take a bibtex file and then format a column of @-tags ("@li2019") into a column of short ("Li (2019)") or long ("'Title of a Good Paper'. Bob Li, 2019 Journal of Cool Stuff vol. 4 no. 20" ) citation. This would be good for literature reviews, meta-analyses, tables of software used/data sources, etc.
Thanks for the great package!
dmi3kno commentedon May 22, 2020
My understand is that the reason @-tags don't work in
gtis because it exports LaTex, butpandocis skipping those tags when parsing the text withpandoc-citeproc. On the other handknitr::kable(format="markdown")exports plain markdown tables and therefore they get properly parsed for @-tags. I don't know if anything can be done at all, since markdown formatting is very limited. Perhaps there's a solution with a different reference processor:natbiborbiblatex, but I don't know enough to speak about that confidently.dmi3kno commentedon May 23, 2020
I think I have a solution.
https://gist.github.com/dmi3kno/016b9ae2d2de1ef54f4df07ebcd24c4d
Key takeaways:
citation_package: natbibfor processing referencesgtand use post-formatting withtools::encoded_text_to_latex()Generally speaking,
fmt(cols, fns=tools::encoded_text_to_latex)seems to be a useful pattern. Would you consider adding it as a standard formatter, i.e.fmt_latex(), @rich-iannone ? Would you like a PR with that?UPDATE
Here's my
[@ref]to\cite{ref}transforming function