pandoc-ext / section-bibliographies Goto Github PK
View Code? Open in Web Editor NEWFilter to create a separate bibliography for each section or chapter
License: MIT License
Filter to create a separate bibliography for each section or chapter
License: MIT License
As mentioned in #6 (comment) the filter ignores the metadata field nocite
. (And suppress-bibliography
?)
I can see two valid uses of the metadata nocite
:
nocite
citations in this biblio only.nocite
in each of them. (Not sure why one would want that, but perhaps.)A related issue is whether the filter should provide section-level nocites and how. One solution would be to use special Divs. (Tricky case: a nocite
div is present at the top of a section level 1, but the filter is run asking for bibliographies at section level 2.)
I have an unnumbered chapter (a preface) that should have citations and references just like other chapters, but the filter doesn't appear to generate a reference section for it. (running quarto 1.3.433)
Minimal example:
---
format: pdf
bibliography: example.bib
reference-section-title: References
filters:
- section-bibliographies
citeproc: false
---
# Preface {-}
text citing @frank2012
# Chapter 1
text citing @lewis1973
# Chapter 2
text citing @kraus2019
Contrast with running pandoc's default citation handling, which does include the unnumbered chapter:
---
format: pdf
bibliography: example.bib
reference-section-title: References
citeproc: true
---
# Preface {-}
text citing @frank2012
# Chapter 1
text citing @lewis1973
# Chapter 2
text citing @kraus2019
Seems like this could be due to the filter checking that a section has a number attribute in line 23?
local function is_section_div (div)
return div.t == 'Div'
and div.classes[1] == 'section'
and div.attributes.number
end
Hi,
I am trying to have multiple references sections in my PhD thesis.
One at the end of the "Manuscrit" part and one at the end of each Article (so three)
Unfortunately when I render in pdf, I have the reference title that appears but no references inside.
Here is my _quarto.yml file
project:
type: book
book:
title: "Book_PhD"
author: "Name"
date: "15.06.2023"
chapters:
- index.qmd
- part: "Manuscrit (français)"
chapters:
- Manuscrit/Intro.qmd
- Manuscrit/Part1_Revue.qmd
- Manuscrit/Part2_Terminologie.qmd
- Manuscrit/Part3_Methodo.qmd
- Manuscrit/Part4_Conclusion.qmd
- Manuscrit/references.qmd
- part: "Articles (english)"
chapters:
- Articles/Article1.qmd
- Articles/Article2.qmd
- Articles/Article_Methodology.qmd
filters:
- section-bibliographies
bibliography: Biblio.bib
reference-section-title: References
citeproc: false
format:
html:
theme: cosmo
pdf:
documentclass: scrreprt
include-in-header:
text: |
\usepackage{multirow}
\usepackage{hyperref}
\usepackage[capitalise,noabbrev]{cleveref}
editor: visual
Any idea of what I could try to make the references appear ?
So far, your lua is the only one I have gotten to work for my dissertation. However, my reference lists consistently start on a new page, after the references header, then there is no page break before the new chpater, even if the new chapter is a separate file.
I think the issue is that I call pagebreak or newpage just before the next chapter heading and your code thinks it's supposed to come before the reference list, then doesn't call newpage after the reference list. Is there a way to override this? I'm using pandoc in RStudio on Windows.
Thanks!
Environment: RStudio 2022.12.0+353 for Ubuntu Jammy
I am writing a scientific manuscript using Quarto/RStudio. I just installed the section-bibliographies filter as an extension using quarto install extension pandoc-ext/section-bibliographies
which concluded with "Extension installation complete". I also now see the _extensions/pandoc-ext/section-bibliographies subdirectories in the project directory. I then updated my yaml as described in the section-bibliographies/README. However, when I render the .qmd file, it errors with "Error running filter section-bibliographies: Could not find executable section-bibliographies". I've looked for solutions to this issue, but have come up empty and am hoping you can help. Thanks.
Hello
thanks for a great filter. Is there a way to specify where the references go? For context I'm working in quarto books -- the references just appear at the end of each section, and disregard the
::: {#refs}
:::
that I had included to make the references appear earlier.
I haven't found any way to do this, is it possible? Thanks again
It seems that the lang argument in quarto chapter _metadata.yml or yaml header is not taken into account for pdf output. Only the lang argument in _quarto.yml is taken into account.
Here are the files used to reproduce this bug :
project:
type: book
lang: fr
book:
chapters:
- index.qmd
- fr.qmd
- en.qmd
bibliography: references.bib
filters:
- section-bibliographies
format:
html:
theme: cosmo
pdf:
documentclass: scrreprt
citeproc: false
editor: visual
# Preface {.unnumbered}
---
lang: en
---
# English
[@ethier2020]
---
lang: fr
---
# French
[@ethier2020]
@article{ethier2020,
title = {Using microphone arrays to investigate microhabitat selection by declining breeding birds},
author = {Ethier, Jeffrey P. and Wilson, David R.},
year = {2020},
month = {07},
date = {2020-07-01},
journal = {Ibis},
pages = {873--884},
volume = {162},
number = {3},
doi = {10.1111/ibi.12785},
note = {DOI: 10.1111/ibi.12785
MAG ID: 2977097847}
}
The outputs of these files running quarto render index.qmd
are a html website with correct citation, i.e. "and" between authors names for english chapter and "et" between authors names for french chapter, and a pdf file with only french formated citations (as lang: fr
is specified in _quarto.yml
).
Hi. I managed to generate the per-chapter references but the header will not follow the proper numbering. In the example below, it should be numbered as 2.8
Here is the relevant part of the config file:
project:
type: book
book:
title: "my book title"
author: "Felipe Almeida"
date: "5/13/2023"
chapters:
- index.qmd
- chapters/ch_01.qmd
- part: parts/part_01.qmd
chapters:
- chapters/ch_02.qmd
filters:
- section-bibliographies
bibliography: references.bib
reference-section-title: References
format:
html:
toc: true
toc-expand: 1
toc-depth: 4
pdf:
documentclass: scrreprt
crossref:
chapters: true
This package is great. I'm using it to format my CV. I noticed the section-bibs-level
parameter wasn't working for me, Regardless of what value I set for section-bibs-level, it all refs were assigned to the top level headers.
I fixed it for my use case (wanting citations to follow second level headers) making a small change
if not header or section_refs_level < header.level then
-- Don't do anything for lower level sections.
return nil
elseif section_refs_level == header.level then
blocks = div.content
subsections = pandoc.List:new{}
I edited changed the < in line 78 to > & the == in line 81 to <
if not header or section_refs_level > header.level then
-- Don't do anything for lower level sections.
return nil
elseif section_refs_level < header.level then
blocks = div.content
subsections = pandoc.List:new{}
This might break things in other use cases, so theres probably a better fix for this issue.
There some demand for recursive citations, i.e. handling \cite commands within the bibliographies themselves, usually in the BibTeX note field. See this exchange on pandoc-discuss. Would you be interested in a PR adding this?
I've written a recursive citeproc filter that we use in the journal dialectica. I'm considering updating it for Quarto, but I'd be glad to contribute to section-bibliographies and multibib and use one of these instead.
I'd try to make the addition as lightweight as possible when no recursion is needed by first scanning the first citeproc pass's output with a filter {{ Citation = function(elem) has_citations = true end }}
.
I updated my Quarto today to version 1.3.361 (the current main version) and all my section bibliographies went blank (i.e., no bibliography was rendered at all). I reverted back to version 1.2.475 that I had been using and they reappeared. Is this something other people have experienced?
In the installation instruction for Quarto
, the command is given as,
quarto install extension tarleb/section-bibliographies
when I run this from Rstudio Cloud, I got this error,
Extension not found in local or remote sources
Now after going through the documentation of Quarto extension,
I tried the following command,
quarto install extension pandoc-ext/section-bibliographies
It worked smoothly.
Hello,
The filter works great when the chapters are normally numbered but when there is an unnumbered chapter (e.g., the Introduction of my thesis has the number 0 so that the following chapters ~ papers are numbered from 1). I use RMarkwdown, the chapters are added as child documents. Knitting to PDF using pdflatex.
Also, I believe it worked for the first time but ignored \newpage for new chapters. When I played with it a bit, the reference list for chapter 0 disappeared and the \newpage started to work.
Is there a way to suppress the final full list of references which gets rendered automatically?
I'm working in RMarkdown. SessionInfo:
R version 4.2.2 Patched (2022-11-10 r83330)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.5 LTSMatrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=cs_CZ.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=cs_CZ.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=cs_CZ.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=cs_CZ.UTF-8 LC_IDENTIFICATION=Cattached base packages:
[1] stats graphics grDevices utils datasets methods baseother attached packages:
[1] lmerTest_3.1-3 lme4_1.1-31 Matrix_1.5-3loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 mvtnorm_1.1-3 lattice_0.20-45 zoo_1.8-11
[5] assertthat_0.2.1 digest_0.6.30 utf8_1.2.2 R6_2.5.1
[9] cellranger_1.1.0 coda_0.19-4 evaluate_0.18 ggplot2_3.4.0
[13] pillar_1.8.1 gdtools_0.2.4 rlang_1.0.6 multcomp_1.4-20
[17] uuid_1.1-0 readxl_1.4.1 rstudioapi_0.14 minqa_1.2.5
[21] data.table_1.14.6 nloptr_2.0.3 flextable_0.8.3 rmarkdown_2.18
[25] splines_4.2.2 TMB_1.9.1 munsell_0.5.0 compiler_4.2.2
[29] numDeriv_2016.8-1.1 xfun_0.35 pkgconfig_2.0.3 systemfonts_1.0.4
[33] base64enc_0.1-3 htmltools_0.5.3 tidyselect_1.2.0 tibble_3.1.8
[37] glmmTMB_1.1.5 codetools_0.2-18 fansi_1.0.3 dplyr_1.0.10
[41] MASS_7.3-58.1 grid_4.2.2 nlme_3.1-160 xtable_1.8-4
[45] gtable_0.3.1 lifecycle_1.0.3 DBI_1.1.3 magrittr_2.0.3
[49] scales_1.2.1 zip_2.2.2 estimability_1.4.1 cli_3.4.1
[53] xml2_1.3.3 generics_0.1.3 vctrs_0.5.1 boot_1.3-28.1
[57] sandwich_3.0-2 TH.data_1.1-1 tools_4.2.2 forcats_0.5.2
[61] glue_1.6.2 officer_0.4.4 emmeans_1.8.2 fastmap_1.1.0
[65] survival_3.4-0 yaml_2.3.6 colorspace_2.0-3 knitr_1.41
The YAML header of my main document:
title: ''
output:
pdf_document:
latex_engine: pdflatex
number_sections: TRUE
pandoc_args: ['--lua-filter=section-bibliographies.lua']
always_allow_html: true
geometry: "left = 4cm, right = 2cm, top = 2cm, bottom = 2cm"
fontsize: 11pt
header-includes:
- \usepackage{float}
- \usepackage{sectsty}
- \usepackage{paralist}
- \usepackage{setspace}\spacing{1.5}
- \usepackage{fancyhdr}
- \usepackage{lastpage}
- \usepackage{dcolumn}
- \usepackage{natbib}
- \usepackage[nottoc, numbib]{tocbibind}
- \usepackage{ragged2e}
- \usepackage{pdflscape}
- \usepackage{textgreek}
- \usepackage{graphicx}
- \usepackage{titlesec}
classoption: twoside
bibliography: library.bib
reference-section-title: References
section-bibs-level: 2
citation_package: biblatex
csl: journal-of-ecology.csl
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.