Open njbart opened 5 years ago
Thanks.
I see the issue but it does not seem easy because I believe the \footnote
is created by Pandoc processing when using the csl chicago-fullnote-bibliography.csl
Am I right with CSL ?
If this above is true, the issue is that the text reference feature is a hack to allow markdown syntax. But I think we move it after the processing by Pandoc. This means that I don't think Pandoc see the reference in a caption and so may not do the correct replacement. I may be wrong though...
Anyway, I believe this would require patching when post processing in this case.
We would love help on this topic that is specific to some use of CSL allowing footnote with references in caption.
@njbart I have a work around. Try my re-implementation of reference text in Lua filter and let kable
output Pandoc's markdown.
bookdown::pdf_document2:
latex_engine: xelatex
pandoc_args:
- "--lua-filter"
- "bookdown-reference-text.lua"
kable(format = "pandoc")
, i.e.
knitr::kable(
cars[1:5, ],
caption = "(ref:aTable-caption)",
format = "pandoc"
)
Thanks a lot @atusy ! Am I right that doing it in a Lua fitler allow to fix
If this above is true, the issue is that the text reference feature is a hack to allow markdown syntax. But I think we move it after the processing by Pandoc. This means that I don't think Pandoc see the reference in a caption and so may not do the correct replacement. I may be wrong though...
I would find it very useful to use a Lua filter for this feature in bookdown. If you are willing to contribute it, it would be quick to have this available. @yihui what do you think about have text reference feature done in Lua ? @atusy does your current filter cover the same scope as bookdown text reference feature ?
Could be limitation with format of table in this case. (Needs to be Markdown)
Also does it solve the issue above by working with CSL chicago-fullnote-bibliography.csl
?
@cderv
I am interested in the contribution, but needs some time.
My implementation still lacks an ability to replace text in the RawBlock
like LaTeX.
I think this requires insertion of Para
within RawBlock
, which would be not straightforward.
Also does it solve the issue above by working with CSL chicago-fullnote-bibliography.csl ?
Yes
Great! don't worry, there is not hurry at all. I can have a look and help improve if you want.
As I just said at https://github.com/rstudio/bookdown/issues/811#issuecomment-827020479, I'm always looking forward to having my R hacks replaced by the Lua filter!
First file,
bookdown_table_caption_citation.Rmd
, adapted from https://stackoverflow.com/questions/46670422/how-to-insert-a-reference-in-a-table-caption-in-a-bookdown-document-that-works-freferences:
latex file (via
keep_tex: yes
):So, in a table apparently handled by rmarkdown/bookdown (rather than pandoc),
\footnote{...}
is placed inside the table caption, with the result that the footnote text is not rendered at all (well-known latex issue).Solution: Have bookdown output
[EDIT: fixed previous line. Just like pandoc, always use the optional argument of
\caption
containing the text to be used if a list of tables is generated by latex (i.e. without any label and footnote stuff). ]instead, and add
outside, probably best immediately after the
table
environment.BTW, this is exactly how pandoc itself solves this issue (see, e.g., https://github.com/jgm/pandoc/issues/1506 and https://github.com/jgm/pandoc/issues/4683).
By filing an issue to this repo, I promise that
xfun::session_info('bookdown')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('rstudio/bookdown')
.I understand that my issue may be closed if I don't fulfill my promises.