Pandoc: Citing a Full Source

439 Views Asked by At

for the purpose of creating a syllabus, I like to know whether it is possible to insert a citation as a full citation. Right now, I have following markdown code:

# Session 1

@zhu2015.

This converts (pandoc "document.md" -o "document.pdf" --from markdown --template "eisvogel" --listings --citeproc) in the pdf as


Session 1

Zhu and Basar (2015).

Bibliography

Zhu, Quanyan, and Tamer Basar. 2015. “Game-Theoretic Methods for Robustness, Security, and Resilience of Cyberphysical Control Systems: Games-in-Games Principle for Optimal Cross-Layer Resilient Control Systems.” Control Systems, IEEE 35 (1): 46–65.


However, would it be possible to insert the reference as a full-citation in text?

Such as:


Session 1

Zhu, Quanyan, and Tamer Basar. 2015. “Game-Theoretic Methods for Robustness, Security, and Resilience of Cyberphysical Control Systems: Games-in-Games Principle for Optimal Cross-Layer Resilient Control Systems.” Control Systems, IEEE 35 (1): 46–65.


Thanks for your help!

1

There are 1 best solutions below

1
On

Here's how to do this with a Lua filter: First, the filter finds the generated bibliography entry and saves it to a table, indexed by the citation key. Then it looks for the citation and replaces it with the full entry.

local refs = {}

local function store_refs (div)
  local ref_id = div.identifier:match 'ref%-(.*)$'
  if ref_id then
    refs[ref_id] = div.content
  end
end

local function replace_cite (cite)
  local citation = cite.citations[1]
  if citation and refs[citation.id] and #cite.citations == 1 then
    return pandoc.utils.blocks_to_inlines(refs[citation.id])
  end
end

return {
  {Div = store_refs},
  {Cite = replace_cite},
}

Save the above to a file and pass that file to pandoc with the --lua-filter command line option. The filter must run after the citeproc processer has done its work, so it should be the last command line argument. Tested with the latest pandoc version 2.12 (which no longer requires pandoc-citeproc, but it should work either way).