Have intext citations that link to PDFs stored in Zotero #13253
Replies: 2 comments
-
You can write a LUA filter. local references = {}
function get_references(doc)
references = pandoc.utils.references(doc)
return doc
end
function process_citations(elem)
local cite_id = elem.citations[1].id
-- Find the reference by ID
local ref = nil
for _, reference in ipairs(references) do
if reference.id == cite_id then
ref = reference
break
end
end
if ref and ref.DOI then
local doi_text = pandoc.utils.stringify(ref.DOI)
local doi_url = "https://doi.org/" .. doi_text
local doi_link = pandoc.Link({pandoc.Str("DOI")}, doi_url)
return {elem, pandoc.Str(" "), doi_link}
end
return elem
end
return {
{ Pandoc = get_references },
{ Cite = process_citations }
} You would need this filter to come after Quarto's processing. filters:
- path: citation.lua
at: post-quarto |
Beta Was this translation helpful? Give feedback.
-
Thank you for your response. I'm rather inexperienced when it comes to making lua filters (I've already made a few little lua filters for my intended use case) and I think it might be difficult to implement the desired feature as a lua filter because I need a way to relate the citekey to a filepath to the reference pdf, not the DOI really. Also, I'm not sure how it would behave if I made a compound parenthetical citation like [@ref1; @ref2]. My initial idea was that I could add a link within the manuscript PDF that leads to the reference's PDF. But I think this is a PDF attachment and not exactly a link. Anyway, I think I can settle on the ff. workflow which already works on my end. It would also be nice if Quarto found a way to make this easier for everyone else.
![]()
![]() I made a YAML parameter called pdfembeds, with options "T" or "F" to control whether pdf attachments appear or not. The following codeblock is the code I put in my \def\paramembeds{$params.pdfembeds$}
\def\classTembeds{T}
\def\classFembeds{F}
\if\paramembeds\classTembeds
\usepackage{attachfile2}
\fi
\if\paramembeds\classFembeds
\usepackage{attachfile} %%loading this package somehow makes attachments not appear for some reason, which is what i want
\fi
![]() ![]() |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Link to PDF from intext / inline citation instead of to bibliography
Sorry if this isn't really a Quarto thing. I'm in the process of writing my thesis, and I really like how Quarto has made me focus more on writing than formatting (cuz I made a template for my thesis), while usingg rbbt to link to Zotero and make my citations and bibliography.
I think that it'd be very helpful to share my manuscript alongside the PDF files, so that when someone is reading the manuscript, they can click on the intext citation and it'd take them to the PDF (or maybe even at a specific page or selection).
It's very difficult somehow to see this asked in the internet, but I found this: (Link to PDF from citation in Docs?), and it's pretty much the most similar to my desired feature.
I think this can be done by duplicating and storing all the reference PDFs in a folder, and have the Quarto intext citation reference that PDF. Then the exported manuscript and the PDF folder can be shared together to allow readers to also see the sources themselves. This would be really helpful when multiple people need to check each other's work, like my adviser reading my manuscript.
Beta Was this translation helpful? Give feedback.
All reactions