zepinglee / citeproc-lua

A Lua implementation of the Citation Style Language (CSL)
MIT License
62 stars 7 forks source link

Option to stop citation appearing in bibliography? #31

Closed nickw2066 closed 11 months ago

nickw2066 commented 1 year ago

Hi, Is there an option to cite something but stop it appearing in the bibliography? Like this Biblatex feature?

\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\addbibresource{/path/to/references.bib}
\DeclareBibliographyCategory{ignore}
\addtocategory{ignore}{johnson2015}
\addtocategory{ignore}{doe1986}

\begin{document}

\cite{johnson2015},
\cite{smith2015},
\cite{doe1986},
\cite{samson2012}

\printbibliography[notcategory=ignore]
\end{document}

I need to cite a book review but it's not meant to appear in my bibliography. Thanks, Nick

zepinglee commented 1 year ago

It's reasonable and I'll prioritize this feature.

zepinglee commented 1 year ago

I've just added the type, nottype, keyword, notkeyword, category, and notcategory options to \printbibliography as well as \DeclareBibliographyCategory and \addtocategory commands (see the test file bib-filter.lvt). All of them work in the same way as in biblatex. The filter and \defbibfilter in biblatex are not implemented at the moment.

bemilton commented 1 year ago

@zepinglee Could you add a capability to define title when selecting by category? For example: there's an overleaf example here using package biblatex.

Unfortunately, with citation-style-language package there is an (ignored) error due to title option:

! LaTeX Error: The key 'csl/bibliography/title' is unknown and is being (LaTeX) ignored.

The rendered PDF simply repeats "References" (when using \documentclass[11pt]{article}) per each \printbibliography[category={phys}, title={test}].

So as a minimum working example re-using the OP's code:

\documentclass{article}
\usepackage[style=ieee]{citation-style-language}
\addbibresource{/path/to/references.bib}
\DeclareBibliographyCategory{ignore}
\addtocategory{ignore}{johnson2015}
\addtocategory{ignore}{doe1986}

\begin{document}

\cite{johnson2015},
\cite{smith2015},
\cite{doe1986},
\cite{samson2012}

\printbibliography[notcategory=ignore]
\printbibliography[category=ignore, title={Ignored References}]
\end{document}
zepinglee commented 1 year ago

@bemilton I've just added the heading and title options and the above example works fine. The related documentation will be added later.

bemilton commented 1 year ago

@zepinglee Brilliant, thank you for rapid solution. By the way -- it is an excellent tex package!