I would like to write all parenthetical citations in small fonts when I produce HTML/revealjs outputs from markdown using pandoc. Putting <small>...</small>
tags around the [@citation]
notation (e.g. <small>[@citation]</small>
) can be the way to achieve that effect, but I just leave [@citation]
s as they are since there are a lot of [@citation]
in my multiple .md
files.
I came up with the following lua-filter (say small-parencite.lua
) that selectively makes the font size of parenthetical citations small. However, this lua-filter does not change the font size of any parenthetical citation.
Cite = function(cite)
content = cite.content
-- if FORMAT:match 'html' or FORMAT:match 'revealjs' then
if cite.citations == 'NormalCitation' then
pandoc.Str('<small>' .. content .. '</small>')
end
-- end
return cite
end
Does anybody point out what I am missing in that lua-filter? Note that I want the font size of narrative citations to remain the same as normal texts as shown below:
small-parencite.lua
Cite = function(cite)
content = cite.content
-- if FORMAT:match 'html' or FORMAT:match 'revealjs' then
if cite.citations == 'NormalCitation' then
pandoc.Str('<small>' .. content .. '</small>')
end
-- end
return cite
end
test.md
---
output:
html_document:
md_extensions: -ascii_identifiers
pandoc_args:
- small-parencite.lua
references:
- author:
- family: Allaire
given: JJ
- family: Xie
given: Yihui
- family: McPherson
given: Jonathan
- family: Luraschi
given: Javier
- family: Ushey
given: Kevin
- family: Atkins
given: Aron
- family: Wickham
given: Hadley
- family: Cheng
given: Joe
- family: Chang
given: Winston
- family: Iannone
given: Richard
id: R-rmarkdown
issued: 2020
note: R package version 2.3
title: "rmarkdown: Dynamic Documents for R"
title-short: rmarkdown
type: book
url: "https://github.com/rstudio/rmarkdown"
- author:
- family: Xie
given: Yihui
edition: 2nd
id: knitr2015
issued: 2015
note: ISBN 978-1498716963
publisher: Chapman; Hall/CRC
publisher-place: Boca Raton, Florida
title: Dynamic Documents with R and knitr
type: book
url: "https://yihui.org/knitr/"
---
I want to write all parenthetical citations in small fonts like this:
This is knitr <small>[@knitr2015]</small>.
But I do not want to use `<small>...</small>` tags (e.g. `<small>[@citation]</small>`) to achieve that effect. I just leave `[@citation]`s as they are like this:
This is knitr [@knitr2015]
Note that I want the font size of narrative citations to remain the same as normal texts as shown below:
This is a markdown variant by @R-rmarkdown.
# References
Is this what you want?
function Cite(el)
if el.citations[1].mode == 'NormalCitation' then
return {
pandoc.RawInline("html", "<small>"),
el,
pandoc.RawInline("html", "</small>")
}
end
end