cboettig / knitcitations

:package: Generate citations for knitr markdown and html files
http://carlboettiger.info
Other
220 stars 28 forks source link

Print part of the bibliography #46

Open trinker opened 10 years ago

trinker commented 10 years ago

@cboettig I use knitcitations with slidify. When I print the references I want to print just some of the reverences at a time so that I can stretch multiply slides as the reference list is likely to exceed one slide.

Let's say we have 10 references total being used. If there a way to print the first 5 on one slide and the last 5 on the next slide?

I tried


---

## Ref 2

'''{r, echo=FALSE, results='asis'}
bibliography("html")[1:5]
'''

---

## Ref 1

'''{r, echo=FALSE, results='asis'}
bibliography("html")[6:10]
'''

Note: I replaced the the back ticks in the code chunk with a straight quote as the back ticks won't render on github.

cboettig commented 10 years ago

@trinker That makes sense; not currently possible since bibliography is a print method that invisibly returns bibliography while displaying the formatted output with cat(), see https://github.com/cboettig/knitcitations/blob/master/R/bibliography.R

Well, you could probably hack it by doing:

'''{r include=FALSE}
out <- bibliography("html") # displays nothing but captures the output
'''

Followed by

'''{r results="asis"}
cat(out[1:5])
'''

but I realize that's kinda silly. I'd welcome a pull request that adds this as an option to bibliography... (otherwise I'll get around to it eventually...)