Skip to content

Commit f828e9b

Browse files
OmikhleiaDidier Willis
authored andcommitted
feat(packages): Add \nocite for marking a bibliography entry as cited
Marking an entry for inclusion in the bibliography of cited works even if not actually cited.
1 parent 9ca75ec commit f828e9b

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

packages/bibtex/init.lua

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ function package:registerCommands ()
398398
parseBibtex(file, SILE.scratch.bibtex.bib)
399399
end)
400400

401+
self:registerCommand("nocite", function (options, content)
402+
self:getEntryForCite(options, content, false)
403+
end, "Mark an entry as cited without actually producing a citation.")
404+
401405
-- LEGACY COMMANDS
402406

403407
self:registerCommand("bibstyle", function (_, _)
@@ -420,7 +424,7 @@ function package:registerCommands ()
420424
local cite = Bibliography.produceCitation(options, SILE.scratch.bibtex.bib, bibstyle)
421425
SILE.processString(("<sile>%s</sile>"):format(cite), "xml")
422426
end
423-
end)
427+
end, "Produce a single citation.")
424428

425429
self:registerCommand("reference", function (options, content)
426430
local style = SILE.settings:get("bibtex.style")
@@ -442,7 +446,7 @@ function package:registerCommands ()
442446
end
443447
SILE.processString(("<sile>%s</sile>"):format(cite), "xml")
444448
end
445-
end)
449+
end, "Produce a single bibliographic reference.")
446450

447451
-- CSL IMPLEMENTATION COMMANDS
448452

@@ -542,7 +546,7 @@ function package:registerCommands ()
542546

543547
SILE.processString(("<sile>%s</sile>"):format(cite), "xml")
544548
end
545-
end)
549+
end, "Produce a single citation.")
546550

547551
self:registerCommand("csl:reference", function (options, content)
548552
local entry, citnum = self:getEntryForCite(options, content, true)
@@ -554,7 +558,7 @@ function package:registerCommands ()
554558

555559
SILE.processString(("<sile>%s</sile>"):format(cite), "xml")
556560
end
557-
end)
561+
end, "Produce a single bibliographic reference.")
558562

559563
self:registerCommand("printbibliography", function (options, _)
560564
local bib
@@ -598,7 +602,7 @@ function package:registerCommands ()
598602
SILE.processString(("<sile>%s</sile>"):format(cite), "xml")
599603

600604
SILE.scratch.bibtex.cited = { keys = {}, citnums = {} }
601-
end)
605+
end, "Produce a bibliography of references.")
602606
end
603607

604608
package.documentation = [[
@@ -663,6 +667,9 @@ To produce an inline citation, call \autodoc:command{\csl:cite{<key>}}, which wi
663667
If you want to cite a particular page number, use \autodoc:command{\csl:cite[page=22]{<key>}}. Other “locator” options are available (article, chapter, column, line, note, paragraph, section, volume, etc.) – see the CSL documentation for details.
664668
Some frequent abbreviations are also supported (art, chap, col, fig…)
665669
670+
To mark an entry as cited without actually producing a citation, use \autodoc:command{\nocite{<key>}}.
671+
This is useful when you want to include an entry in the bibliography without citing it in the text.
672+
666673
To produce a bibliography of cited references, use \autodoc:command{\printbibliography}.
667674
After printing the bibliography, the list of cited entries will be cleared. This allows you to start fresh for subsequent uses (e.g., in a different chapter).
668675
If you want to include all entries in the bibliography, not just those that have been cited, set the option \autodoc:parameter{cited} to false.

0 commit comments

Comments
 (0)