Git Product home page Git Product logo

citeproc-lua's People

Contributors

dependabot[bot] avatar josephwright avatar michal-h21 avatar zepinglee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

citeproc-lua's Issues

Excessive whitespace before references in some citation styles

When using some citation styles (Vancouver, IEEE, probably others...) the reference list will be shoved off to the right side of the page (often completely departing the visible document area) by a large quantity of whitespace (LaTeX complains about overfull hboxes).
This can be seen with the project's own example by changing the citation style from APA to Vancouver.
Attempting to reproduce it using the example with the IEEE style gives me a "Misplaced tab alignment character &.", but commenting lines 20, 44, and 50 will allow it to compile and demonstrate the same issue.

Great project by the way!

Issues compiling minimal example

Hello! I'm really interested in using this package but somehow I can't make it work.
I am trying to compile the same example as in the readme,

\documentclass{article}

\usepackage{citation-style-language}
\cslsetup{style = apa}
\addbibresource{library.bib}

\begin{document}

\cite{Abrams2015a}
\printbibliography

\end{document}

I am on a [derivative of] Ubuntu 20.04, I installed the latest TexLive [2022] manually and the latest Lua.
When I do lualatex test.tex I get

mf-dist/scripts/citation-style-language/citeproc-bib.lua:158: invalid use of '%' in replacement string
stack traceback:
        [C]: in function 'string.gsub'
        ...mf-dist/scripts/citation-style-language/citeproc-bib.lua:158: in function '
citeproc-bib.unescape'
        ...mf-dist/scripts/citation-style-language/citeproc-bib.lua:127: in function '
citeproc-bib.convert_field'
        ...mf-dist/scripts/citation-style-language/citeproc-bib.lua:68: in function 'c
iteproc-bib.parse_item'
        ...mf-dist/scripts/citation-style-language/citeproc-bib.lua:40: in function 'c
iteproc-bib.parse'
        .../texmf-dist/scripts/citation-style-language/csl-core.lua:99: in upvalue 're
ad_data_file'
        .../texmf-dist/scripts/citation-style-language/csl-core.lua:109: in upvalue 'r
ead_data_files'
        .../texmf-dist/scripts/citation-style-language/csl-core.lua:126: in function '
csl-core.make_citeproc_sys'
        .../texmf-dist/scripts/citation-style-language/csl-core.lua:162: in function '
csl-core.init'
        ...stall/texmf-dist/scripts/citation-style-language/csl.lua:34: in function 'c
sl.init'
        [\directlua]:1: in main chunk.
\lua_now:e #1->\__lua_now:n {#1}

where the interesting bit is scripts/citation-style-language/citeproc-bib.lua:158: invalid use of '%' in replacement string. I commented that line out and ran again and this time I got a similar error that says

scripts/citation-style-language/citeproc-bib.lua:405: bad argument #1 to 'lower' (string expected, got nil)

so I went to that line and changed

  if bib_fields.eprint and string.lower(bib_fields.eprinttype) == "pubmed" and not item.PMID then

to

  if bib_fields.eprint and bib_fields.eprinttype and string.lower(bib_fields.eprinttype) == "pubmed" and not item.PMID then

to avoid the error. Now when I run lualatex it kinda hangs, cpu working but nothing really happening.

Can you help me out?
Thanks in advance!

Sorting the citations

Describe the bug
With two citations of the same year by the same author we get for example <author>1988a, 1988b
when using biblatex and an authoryear style. With citation-style-language we get it the other way round
(see screenshot)

Additional information

  • TeX distribution: [TeX Live 2023, MacTeX 2023]
  • Package citation-style-language version: [e.g. v0.4.4, main branch]
  • LaTeX engine: [e.g. lualatex]

To Reproduce

\documentclass[]{article}
\usepackage{citation-style-language} 
\cslsetup{style=turabian-author-date} 
%\usepackage[style=authoryear]{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}

\cite{nietzsche:ksa,nietzsche:ksa1} 
\printbibliography

\end{document}

Screenshots

Bildschirmfoto 2023-10-03 um 21 40 21

Duplicate citekeys discard bibliography

When you have duplicate citekyes in the bibliography source file, Citeproc issues runtime error:

Module csl Error: Duplicate entry key "texbook" in "examples.bib". on input line 7

stack traceback:
        [C]: in function 'error'
        ...ocal/texlive/2022/texmf-dist/tex/latex/base/ltluatex.lua:110: in field 'module_error'
        ...ichal/texmf/scripts/citation-style-language/csl-core.lua:21: in function 'csl-core.error'
        ...ichal/texmf/scripts/citation-style-language/csl-core.lua:115: in upvalue 'read_data_files'
        ...ichal/texmf/scripts/citation-style-language/csl-core.lua:126: in function 'csl-core.make_citeproc_sys'
        ...ichal/texmf/scripts/citation-style-language/csl-core.lua:162: in function 'csl-core.init'
        /home/michal/texmf/scripts/citation-style-language/csl.lua:34: in function 'csl.init'
        [\directlua]:1: in main chunk.
\lua_now:e #1->\__lua_now:n {#1}
                                 
l.7 \begin{document}
                   

What is worse, processing of the bibliography and in-text citations fails, nothing is produced. I've found this thanks to this question on TeX.sx.

Here is a MWE:

\documentclass{article}

\usepackage{citation-style-language}
\cslsetup{style = apa}
\addbibresource{examples.bib}

\begin{document}

\cite{texbook}
\printbibliography

\end{document}

examples.bib:

@book{texbook,
  author = {Donald E. Knuth},
  year = {1986},
  title = {The {TeX} Book},
  publisher = {Addison-Wesley Professional}
}

@book{texbook,
  author = {Donald E. Knuth},
  year = {1986},
  title = {The {TeX} Book},
  publisher = {Addison-Wesley Professional}
}


Long cite not working

I can't seem to get a long citation to appear.
I'm using the turabian-fullnote-bibliography.csl file (standard CSL, no changes on my part).

I've attached a Word document and Word PDF to show that the long citation appears in Word (through Zotero, using the same style: Turabian 8th edition [full note]).
testLongCiteWord.docx
testLongCiteWord.pdf

I've also attached the output PDF produced by lualatex.
testLongCite.pdf

Here is my tex file:

\documentclass[12pt]{article}

\usepackage{citation-style-language}
\cslsetup{style = turabian-fullnote-bibliography}
\addbibresource{myBib.json}

\begin{document}

Bruce Metzger said that.\cite{Metzger2005-TheTex}

\end{document}

Here is my JSON bibliography:

[
    {
        "id": "Metzger2005-TheTex",
        "type": "book",
        "author": [
            {
                "family": "Metzger",
                "given": "Bruce M."
            },
            {
                "family": "Ehrman",
                "given": "Bart D."
            }
        ],
        "title": "The Text of the New Testament: Its Transmission, Corruption, and Restoration",
        "title-short": "Text of the New Testament",
        "edition": "4",
        "publisher-place": "New York, NY",
        "publisher": "Oxford University Press",
        "issued": {
            "date-parts": [
                [
                    "2005"
                ]
            ]
        }
    }
]

What am I doing wrong?

djot/djot-lua head's up

Nothing specific, but thought you should know about this @zepinglee (will have an iteration of the pandoc citation support "soon").

https://github.com/jgm/djot.lua

Would suggest making sure, if feasible and practical, that you don't always assume a TeX backend.

For example, this module for the lua-based Sile typesetting system already supports it.

https://github.com/Omikhleia/markdown.sile
https://github.com/Omikhleia/markdown.sile#native-djot-package

And they have an issue for bib support:

Omikhleia/markdown.sile#10

I can't get citeproc-lua to work on Texifier for macOS

I've installed everything correctly. I've read the package documentation from top to bottom thrice. And I just can't make the package work. Every time I run a super simple code I get from 177 to 186 errors saying things like:

  • citation-style-language error: "incompatible-package". The 'babelbib' package is incompatible with `citation-style-language'.
  • citation-style-language error: "incompatible-package". The 'biblatex' package is incompatible with `citation-style-language'.
  • citation-style-language error: "incompatible-package". The 'bibtopic' package is incompatible with `citation-style-language'.
  • citation-style-language error: "incompatible-package". The 'bibunits' package is incompatible with `citation-style-language'.
  • citation-style-language error: "incompatible-package". The 'chapterbib' package is incompatible with `citation-style-language'.
  • citation-style-language error: "incompatible-package". The 'cite' package is incompatible with `citation-style-language'.
  • LaTeX error: "kernel/property-unknown".
  • The key property '.prop_put:N' is unknown.
  • 'csl/cite-item/prefix': this property is not defined.
  • AND MANY, MANY MORE.

The fact is that I'm not using any of those packages (at least not intentionally). This is my code:

\documentclass{article}

\usepackage[style = apa]{citation-style-language}

\addbibresource{thesis-bibliography.json}

\begin{document}

\cite[prefix = {See }, page = 42]{russellDenoting1905}
\printbibliography

\end{document}

Additional information

  • TeX distribution: MacTeX 2023
  • Package citation-style-language
  • LaTeX engine: TexpadTeX

<span class=“nocase”>\{}noopsort</span> and <span class=“nocase”> printed

Hi,

I have the following author problem:
bib (Zotero BBT export):

@article{vansteenis1998c,
  title = {Description of and key to the {{European}} females of the {{{\emph{Platycheirus}}}} {\emph{peltatus}} sub-group ({{Diptera}}, {{Syrphidae}}), with a description of the male and female of {{P}}. {\emph{islandicus}} {{Ringdahl}}, 1930, stat. n},
  author = {{\noopsort{steenis}}{van Steenis}, J. and {Goeldlin de Tiefenau}, P.},
  year = {1998},
  journal = {Bulletin de la Société Entomologique Suisse},
  volume = {71},
  pages = {187--199},
  keywords = {⛔ No DOI found},
  groups = {taxofly},
  timestamp = {2022-10-29T12:36:46Z}
}
@preamble{ "\providecommand{\noopsort}[1]{} " }

tex

\documentclass[english]{article}
\usepackage{citation-style-language}
\cslsetup{style = zootaxa}
\addbibresource{../../taxofly.bib}
\begin{document}
\section{Citing Example}
Lorem ipsum dolor sit amet laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu \cite[some text]{vansteenis1998c} fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\nocite{*}
\printbibliography
\end{document}

Prints:

Lorem ipsum dolor sit amet laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
eu J. <span class=“nocase”>\{}noopsort</span><span class=“nocase”>stee-
nis</span><span class=“nocase”>van Steenis</span>, <span class=“nocase”>Goeldlin
de Tiefenau</span>, et al. (1998), some text fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.

Problem:
Some how the <span ..> are printed and should not be? ..or howe to get rid of them?

Option to stop citation appearing in bibliography?

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

Bug with lualatex and a nonbreakspace in the locale file

Describe the bug
running this with pdflatex or xelatex works fine.
But running with lualatex the &#160; in the file csl-locales-de-DE.xml
which should be a non breakable space is for lualatex a linebreak (see
image and the linebreak between u. a., which is et al in german).

If I change the &#160; to &ThinSpace; in the file csl-locales-de-DE.xml,
(line no 77 , localisation for et-al), then it works for lualatex, but
gives an error for pdflatex.

Additional information

  • TeX distribution: [TeXLive 2023, MacTeX 2023]
  • Package citation-style-language version: [e.g. v0.4.4]
  • LaTeX engine: [e.g. pdflatex / xelatex / lualatex]

To Reproduce

\documentclass{article}
\usepackage{libertinus}
\usepackage[ngerman]{babel}
\usepackage[style=modern-language-association]{citation-style-language}
\addbibresource{biblatex-examples.bib}
\begin{document}
~\parencite{aksin}
\printbibliography
\end{document}

Screenshots
Bildschirmfoto 2023-09-25 um 10 53 01

main: Error compiling example.tex in pdflatex

When using the version on main, pdflatex example.tex gives out the following error:

> \g__csl_bibliography_setup_tl=\cslsetup { class = in-text, hanging-indent =
true, line-spacing = 2, entry-spacing = 0, }.
<recently read> }

l.19 \begin{document}

?

Using lualatex does not give out this error.

Cite in csquotes' blockquote not working

I'm note sure why this code won't compile:

\documentclass[12pt]{article}

\usepackage{citation-style-language}
\cslsetup{style = turabian-fullnote-bibliography}
\addbibresource{myBib.json}

\usepackage{csquotes}

\begin{document}

\blockquote{Bruce Metzger said that.\cite{Metzger2005-TheTex}\relax}

\end{document}

Here is my JSON file:

[
    {
        "id": "Metzger2005-TheTex",
        "citation-key": "Metzger2005-TheTex",
        "type": "book",
        "author": [
            {
                "family": "Metzger",
                "given": "Bruce M."
            },
            {
                "family": "Ehrman",
                "given": "Bart D."
            }
        ],
        "title": "The Text of the New Testament: Its Transmission, Corruption, and Restoration",
        "title-short": "Text of the New Testament",
        "edition": "4",
        "publisher-place": "New York, NY",
        "publisher": "Oxford University Press",
        "issued": {
            "date-parts": [
                [
                    "2005"
                ]
            ]
        }
    }
]

The error given is:
! Argument of \csq@getcargs@ii has an extra }. <inserted text> \par l.11 ... said that.\cite{Metzger2005-TheTex}\relax}

If you spot my error please let me know.

support for `bibtex`/`natbib` command `\citeyearpar` (equivalent to `biblatex` command `\parencite*`) [improving compatibility]

I have not tried this package in LaTeX yet, but it looks very handy and a game changer (for sure) to boost citation formatting!

I always work with "author-year" (e.g. Harvard family) citation styles. Usually, I have several citations in the form of "year-only" as the author(s) are typed explicitly in the text. The latex commands are \citeyearpar in natbib/bibtex, or the \parencite* in biblatex.

This package ("citation-style-language"/ "citeproc-lua") appears to not provide the translation of the above ("year-only") citation commands. I have scanned the source files in this repo and found the "suppress-author" property, defined at: #L199

I am curious to see if the following code can provide the needed feature (i.e. to define a translation for the \citeyearpar and \parencite*):

Edits to the file: ./latex/citation-style-language-cite.sty

  • Add this at Line #34:

\NewDocumentCommand \citeyearpar { o o m } { \__csl_cite_year:nnn {#1} {#2} {#3} }

\NewDocumentCommand \parencite*{ o o m } { \__csl_cite_year:nnn {#1} {#2} {#3} }

  • Add this at Line #114:
    \cs_new:Npn \__csl_cite_year:nnn #1#2#3 { \seq_clear:N \l__csl_cite_keys_seq \seq_clear:N \l__csl_citation_items_seq \prop_clear:N \l__csl_citation_properties_prop \__csl_process_cite_input:nnn {#1} {#2} {#3} \__csl_process_citation_info:NN \l__csl_cite_keys_seq \l__csl_citation_items_seq \prop_put:Nnn \l__csl_citation_properties_prop { noteIndex } { 0 } \prop_put:Nnn \l__csl_citation_properties_prop { mode } { suppress-author} \bool_set_false:N \l__csl_note_bool \__csl_make_citation:N \l__csl_citation_info_prop }

End of suggestions.

I am not sure if the suggestions above will be successful to add the needed feature to provide compatibility for natbib command \citeyearpar and the equivalent biblatex command \parencite*. In particular, I don't know the actual behaviour of \l__csl_citation_properties_prop { mode } { suppress-author}: does it just print the year-only citation?

Thanks for providing such very practical package.

Can't use mathematics notation in prefixes

First of all, thank you very much for creating and maintaining such a helpful tool. I would like to report a bug as follows.

Describe the bug
It's not possible to use mathematics notation in prefixes.

Additional information

  • TeX distribution: TeX Live 2023
  • Package citation-style-language version: 0.4.5
  • LaTeX engine: xelatex

To Reproduce

\documentclass{article}

\begin{filecontents}[overwrite, noheader]{\jobname.json}
[
    {
        "id": "ITEM-1",
        "type": "book",
        "author": [
            {
                "family": "D’Arcus",
                "given": "Bruce"
            }
        ],
        "issued": {
            "date-parts": [
                [
                    2005
                ]
            ]
        },
        "publisher": "Routledge",
        "title": "Boundaries of dissent: Protest and state power in the media age"
    }
]
\end{filecontents}

\usepackage[style = apa]{citation-style-language}
\addbibresource{\jobname.json}
\usepackage{hyperref}

\begin{document}
\cite[prefix = {That typically happens in 10$^{-15}$ seconds. See }]{ITEM-1}

\printbibliography
\end{document}
...exmf/scripts/citation-style-language/citeproc-output.lua:1981: bad argument #1 to 'gsub' (string expected, got table)

New command not working in cite

Describe the bug
Cite is producing an empty footnote.

Additional information

  • TeX distribution: MacTeX 2023
  • Package citation-style-language version: updated today
  • LaTeX engine: lualatex

JSON

[
    {
        "id": "Wallace1996-GreekG",
        "type": "book",
        "author": [
            {
                "family": "Wallace",
                "given": "Daniel B."
            }
        ],
        "title": "Greek Grammar Beyond the Basics: An Exegetical Syntax of the New Testament",
        "title-short": "Greek Grammar",
        "source": "Accordance",
        "publisher-place": "Grand Rapids, MI",
        "publisher": "Zondervan",
        "issued": {
            "date-parts": [
                [
                    "1996"
                ]
            ]
        }
    }
]

No Problem

% !TEX encoding = UTF-8 Unicode
\documentclass[12pt]{article}

\usepackage{citation-style-language}
\cslsetup{style = turabian-fullnote-bibliography}
\addbibresource{myBib.json}

\newcommand{\myCommandToday}{new command}

\begin{document}

Test.\cite[prefix = {new command word.
}, page = {419}]{Wallace1996-GreekG}

\newpage
\printbibliography
\end{document}

Problem

% !TEX encoding = UTF-8 Unicode
\documentclass[12pt]{article}

\usepackage{citation-style-language}
\cslsetup{style = turabian-fullnote-bibliography}
\addbibresource{myBib.json}

\newcommand{\myCommandToday}{new command}

\begin{document}

Test.\cite[prefix = {\myCommandToday word.
}, page = {419}]{Wallace1996-GreekG}

\newpage
\printbibliography
\end{document}

Problematic spacing in citation

Describe the bug
There are unnecessary newlines in the citation.

Additional information

  • TeX distribution: MacTeX 2023, LuaHBTeX, Version 1.17.0 (TeX Live 2023)
  • Package citation-style-language version: v0.4.4
  • LaTeX engine: lualatex

To Reproduce

% !TEX encoding = UTF-8 Unicode
\documentclass[12pt,oneside]{article}

\usepackage{citation-style-language}
\cslsetup{style = turabian-fullnote-bibliography}
\addbibresource{myBib.json}

\begin{document}

Asumsi\cite{Hiebert2006-Hermen}

\end{document}

JSON:

[
    {
        "id": "Hiebert2006-Hermen",
        "type": "chapter",
        "author": [
            {
                "family": "Hiebert",
                "given": "Robert J. V."
            }
        ],
        "editor": [
            {
                "family": "Kraus",
                "given": "Wolfgang"
            }
        ],
        "collection-editor": [
            {
                "family": "Peters",
                "given": "Melvin K. H."
            }
        ],
        "title": "The Hermeneutics of Translation in the Septuagint of Genesis",
        "source": "EBSCO",
        "collection-title": "Society of Biblical Literature Septuagint and Cognate Studies",
        "container-title": "Septuagint Research: Issues and Challenges in the Study of the Greek Jewish Scriptures",
        "page": "85-103",
        "publisher-place": "Atlanta",
        "publisher": "Society of Biblical Literature",
        "issued": {
            "date-parts": [
                [
                    "2006"
                ]
            ]
        }
    }
]

Screenshots
Output:
mwe.pdf

Bug with AZR CSL Style: context.lua:70: attempt to index a nil value (field 'cite')

Describe the bug
When trying to buid a .tex file using the example bib of the AZR csl style I run into the error "context.lua:70: attempt to index a nil value (field 'cite')".

The sample bib can be found here: https://github.com/PhilippTh/austrian-legal-citation-style/blob/master/Beispiele/Beispiele.bib
In the below tex file the content is in a file "min.bib".
The current official csl for AZR can be found here: https://github.com/citation-style-language/styles/blob/master/azr-abkurzungs-und-zitierregeln-der-osterreichischen-rechtssprache-und-europarechtlicher-rechtsquellen.csl
In the below example it is placed as "acr.csl" next to "example.tex"

The error does not happen for all bib entries. zankl_kunstliche_2019 works, while schweighofer_rechtsinformatik_1999 causes the error. A handful of other entries seem to work, while most others also cause it.

When clearing out the bib file and leaving e.g only schweighofer_rechtsinformatik_1999 the issue remains.

For all entries that the error does not happen a correct pdf is created when running lualatex example.tex twice.

Additional information

  • TeX distribution: MiKTeX 23.5 with LuaLaTex Version 1.17.0
  • Package citation-style-language version: 0.4.1
  • LaTeX engine: lualatex [e.g. pdflatex / xelatex / lualatex]

To Reproduce

\documentclass{article}

\usepackage{citation-style-language} 
\usepackage{hyperref}

\addbibresource{min.bib}
\cslsetup{style = azr}

\newcommand\cs[1]{\texttt{\textbackslash #1}}
\pagestyle{empty}
\setlength{\parindent}{0pt}


\begin{document}

\section*{The standard \cs{cite} command}

\cite{schweighofer_rechtsinformatik_1999}

% Print the reference list
\printbibliography

\end{document}

Screenshots
N/A

running citeproc does not produce a bbl file

Running citeproc on the aux file does not produce a bbl file here. I don't get an error message, so I cannot really say more. All I can say is that the sequence mentioned in the readme doesn't do anything for me.

pdflatex test.tex
pdflatex test.aux
pdflatex test.tex

Using lualatex works though.

Refine the API

I was new to Lua when starting project so I followed https://www.lua.org/pil/16.2.html to design the API: CiteProc:new() is used to create a new processor instance and citeproc.lua returns the class table. However the API looks bad after I read https://github.com/luarocks/lua-style-guide and http://hisham.hm/2014/01/02/how-to-write-lua-modules-in-a-post-module-world/. I decide to refactor the code to follow the LuaRocks style.

  • citeproc.lua will return a module table.
  • citeproc.new() will be used to initialize a processor instance.
  • CiteProc:makeBibliography() and CiteProc:makeCitationCluster() will be renamed to make_bibliography and make_citation to meet the naming convention.

@michal-h21 do you have any suggestions?

What is the plan for commands beyond cite?

Just wondering, how are you planning to support citation commands beyond the default \cite?

I see your reasonable discussion of this in the manual, but there is still room for additional options.

For example, citet/textcite can be supported now, and is in some other implementations (pandoc, org, etc). To do it conceptually is basically "author + suppress author".

The support planned for 1.1 is really so that one can define different author rendering in text, and in parentheses (as is required in APA actually).

But FWIW, citeproc-el, which is used in the new org-mode csl processor, has added some additional rendering options.

https://github.com/andras-simonyi/citeproc-el

After going through this with the org-mode citation design, I do think commands are a bit of a rabbit hole, however; it's hard to know what the right balance is.

Conceptually, CSL is designed around an approach similar to the biblatex high-level ("style-independent") commands, like autocite. Perhaps one option is to take a handful of biblatex (and/or natbib; not sure) commands that fit with CSL's design? Maybe textcite, fullcite, nocite to start?

PS - does this mean you've looked at CSL 1.1? Do you see any problem with supporting it in the future?

documentation improvements

First, this looks great!

But I did run into problems being able to run the example file.

  1. I found I got an error about a missing "inspect" package.
  2. I installed that using luarocks, and still got the error.
  3. I then symlinked it to the texmfhome dir, and that ran, but ...
  4. I got an error about a missing locale file.

After I sorted that all out, I did get it to run, with reasonable output, but got an error about an unsupported "en-US" locale.

The cs:alternative extension seems to be not supported

Hi,

As a researcher and developer in Japan, I'm super happy to see that the cs:layout extension of CSL-M has been supported in citeproc-lua. 🙇 I just confirmed that the feature works fine with a few CSL-M style files!

A missing feature is the cs:alternative extension such as alt-translator. Would you happen to have a plan to support the extension?

Here is an example of a bibliography item that contains alt-translator, alt-issued, alt-publisher-place, and alt-publisher.

[
  {
    "id": "morgan2022philosophy",
    "author": [
      {
        "family": "Morgan",
        "given": "Casey"
      },
      {
        "family": "Patrov",
        "given": "Alexei"
      }
    ],
    "citation-key": "morgan2022philosophy",
    "event-place": "Chicago, IL",
    "issued": {
      "date-parts": [[2022]]
    },
    "language": "en>ja",
    "note": "alt-title: 自由意志の哲学\nalt-translator: 鈴木||真紀\nalt-issued: 2023\nalt-publisher-place: 東京\nalt-publisher: 城南大学出版会",
    "publisher": "Imaginary University Press",
    "publisher-place": "Chicago, IL",
    "title": "The Philosophy of Free Will",
    "type": "book"
  }
]

Error compiling example.tex in TeX4ht

Describe the bug
Compiling example.tex in TeX4ht fails and produces the following error:

! Undefined control sequence.
<argument> ...y@tempb {cite.ITEM-1\@extra@b@citeb 
                                                  }\ifx \Hy@tempa \ltx@empty...
l.23 \cite{ITEM-1}
                  
? 
! Emergency stop.
<argument> ...y@tempb {cite.ITEM-1\@extra@b@citeb 
                                                  }\ifx \Hy@tempa \ltx@empty...
l.23 \cite{ITEM-1}

Additional information

  • TeX distribution: TeX Live 2023
  • Package citation-style-language version: 0.4.2
  • LaTeX engine: htlatex

To Reproduce

If you have a full texlive installation, compile example.tex with the commands:

pdflatex example
citeproc-lua example
make4ht -a debug example

Alternatively, if you have docker installed:

docker run \
  --rm \
  texlive/texlive \
  /bin/sh -c '
    git clone https://github.com/zepinglee/citeproc-lua.git && \
    cd citeproc-lua/examples && \
    pdflatex example && \
    citeproc-lua example && \
    make4ht -a debug example \
  '

underscore in .bib file keys causes halt

In a very long .bib, my colleague has collected many items. One item had two keys in it:

  HAL_ID={hal-03186401},
  HAL_VERSION={v1},

When I run this in texlive 2022 (on overleaf, but it's been reproduced outside), it fails to compile with a timeout.

When I remove those two keys, it runs.

Here is a MWE:

\documentclass{article}

\title{citeproc-lua-test}



\begin{filecontents}[overwrite]{\jobname.bib}
   
@incollection{haltest,
  TITLE={{A tale of two funerary traditons: the predynastic cemetery at Kom el-Khilgan (eastern delta)}},
  AUTHOR={Buchez, N. and Midant-Reynes, B.},
  URL={https://hal.archives-ouvertes.fr/hal-03186401},
  BOOKTITLE={{Egypt and its Origins 3. Proceedings of the Third International Conference ''Origin of the State. Predynastic and Early Dynastic Egypt'', London, 27th July-1st August 2008}},
  EDITOR={Ren{\'e}e F. Friedman and Peter N. Fiske},
  PUBLISHER={{Peeters}},
  SERIES={Orientalia Lovaniensia Analecta},
  VOLUME={205},
  PAGES={831--858},
  YEAR={2011},
  HAL_ID={hal-03186401},
  HAL_VERSION={v1},
}

\end{filecontents}

  
\usepackage{citation-style-language}
\cslsetup{style = apa}
\addbibresource{\jobname.bib}

\begin{document}

\cite{haltest}
\printbibliography

\end{document}

using CSL JSON file with addbibresource

Is it possible to use a CSL JSON file directly with \addbibresource{}? Is it even a good idea? I think it could eliminate one potentially lossy references conversion in my workflow.

I'm working with Zotero/Better BibTeX to translate my Zotero references to Bib(La)Tex format. Then using citeproc-lua via the citation-style-language LaTeX package to enable use of CSL styles in my LaTeX documents. If I understand it correctly, citeproc-lua converts from BibTeX to CSL JSON internally.

Zotero/Better BibTeX can export directly from Zotero to CSL JSON (and other formats like YAML, etc., https://github.com/retorquere/zotero-better-bibtex/tree/master/translators). If citeproc-lua/citation-style-language.sty could use the JSON file directly, it could cut out one format conversion.

Issue with hyperref package and % signs in URLs

With the following JSON file:

[
    {
        "id": "McCarthy2007-Biblia5",
        "type": "book",
        "editor": [
            {
                "family": "McCarthy",
                "given": "Carmel"
            },
            {
                "family": "Schenker",
                "given": "A."
            },
            {
                "family": "Goldman",
                "given": "Y. A. P."
            },
            {
                "family": "van der Kooij",
                "given": "A."
            },
            {
                "family": "Norton",
                "given": "G. J."
            }
        ],
        "title": "Biblia Hebraica Quinta: Deuteronomy",
        "title-short": "BHQ Deuteronomy",
        "source": "PDF",
        "volume": "5",
        "publisher-place": "Stuttgart",
        "publisher": "Deutsche Bibelgesellshaft",
        "URL": "https://linker2.worldcat.org/?jHome=https%3A%2F%2Fgldtl.idm.oclc.org%2Flogin%3Furl%3Dhttps%3A%2F%2Flibguides.thedtl.org%2Fc.php%3Fg%3D1208840&linktype=best",
        "issued": {
            "date-parts": [
                [
                    "2007"
                ]
            ]
        },
        "accessed": {
            "date-parts": [
                [
                    "2022",
                    "09",
                    "16"
                ]
            ]
        }
    }
]

this code complies fine:

% !TEX encoding = UTF-8 Unicode
\documentclass[12pt,oneside]{article}

\usepackage{citation-style-language}
\cslsetup{style = apa}
\addbibresource{myBib.json}

\begin{document}

Test\cite[page = 588]{McCarthy2007-Biblia5}

\newpage
\printbibliography
\end{document}

But when I try to use the hyperref package

% !TEX encoding = UTF-8 Unicode
\documentclass[12pt,oneside]{article}

\usepackage{citation-style-language}
\cslsetup{style = apa}
\addbibresource{myBib.json}

\usepackage{hyperref}

\begin{document}

Test\cite[page = 588]{McCarthy2007-Biblia5}

\newpage
\printbibliography
\end{document}

I get the following error (in texmaker):

! File ended while scanning use of \environment thebibliography .<inserted text>\par<> "mwe url percentage.tex"I suspect you have forgotten a `}', causing meto read past where you wanted me to stop.I'll try to recover; but if the error is serious,you'd better type `E' or `X' now and fix your file.! Emergency stop.<> "mwe url percentage.tex" (job aborted, no legal \end found)Here is how much of LuaTeX's memory you used:8329 strings out of 477250100000,552014 words of node,token memory allocated 393 words of node memory still in use:2 hlist, 1 rule, 1 dir, 3 kern, 1 glyph, 2 attribute, 53 glue_spec, 2 attribute_list nodesavail lists: 1:1,2:41,3:10,4:1,5:35,6:3,7:162,8:6,9:41,11:329312 multiletter control sequences out of 65536+60000015 fonts using 723367 bytes77i,5n,74p,245b,325s stack positions out of 10000i,1000n,20000p,200000b,200000s! ==> Fatal error occurred, no output PDF file produced!

When I remove the % signs from the URL in the JSON file, the code (with the hyperref package) compiles fine.

Do you know what the error is?

Thanks,
Nick

Missing hypen with multiple numeric citations

When using a citation style with numeric citations (e.g., nature), a command like "\cite{ProgressAndPromise,10YrsGWAS,GWAScatalog,15YrsGWAS}" generates the superscript citation "14" instead of the expected "1-4".

I've read the documentation for the citation-style-language package, but I cannot see how to fix this seemingly basic problem. What am I missing? I can provide a minimal reproducible example, if needed.

(In-)compatibility with babel package

Hello, am just a user here. Not too deeply involved into any packages.
Still, a BIG THANK YOU for this package! 👍 My utmost gratitude!

The problem:

There seems to be a compatibility issue with the babel package (unless i configured it wrongly).

  • The first run of lualatex works without a hitch.
  • The second run of lualatex took waaaaay to long. I waited 15 minutes until i closed texmaker and then had to force cancel the process in windows task manager.

Minimal non-working example:

\documentclass[12pt,a4paper]{article}

      \usepackage{citation-style-language}
	   \cslsetup{
				style = apa,
				}

	
      \usepackage[english]{babel}

      \addbibresource{bibliography.bib} 

\begin{document}

      test \cite{Glass20210607PGP} test. 

      \printbibliography

\end{document}

Here the bibliographic data:

@Article{Glass20210607PGP,
  author    = {Glass, Nicola},
  date      = {2021-06-07},
  title     = {Proteste Gegen Putschisten – Widerstand in Den Nachbarländern Myanmar Und Thailand},
  doi       = {10.11588/XAREP.00004477},
  url       = {http://crossasia-repository.ub.uni-heidelberg.de/4477/},
  urldate   = {2021-09-08},
  file      = {:Glass (2021) Proteste gegen Putschisten - Widerstand in Maynmar und Thailand.pdf:PDF},
  keywords  = {Political science, FOS: Political science, Military science},
  publisher = {Heidelberg University Library},
  urn       = {urn:nbn:de:bsz:16-crossasiarep-44775},
}

Removing the line \usepackage[english]{babel} leads to a successful compilation within seconds.

Additional info:

I used the version of the citation-style-language package from MiKTeX, which was packaged on 24.01.2022.

default for no defined style

If no style is defined we get the warning message

Package citation-style-language Warning: Style name not specified.

which is okay. But it is more user-friendly if it could use a default style, apa or whatever:

    Package citation-style-language Warning: Style name not specified.
    Will use default style apa ...

The problem is that the warning will be an error when running citeproc-lua

[...]
Database file #1: biblatex-examples.bib
.../scripts/citation-style-language/citeproc-latex-core.lua:218: attempt to concatenate a nil value (local 'style_name')
[...]

citeproc-util.lua:321: bad argument #1 to 'gmatch' (string expected, got table)

Describe the bug
When executing lualatex test.tex or citeproc-lua text.tex, the error mentioned in the title occurs

Additional information

  • TeX distribution: [e.g. TeX Live 2022, MacTeX 2022, TeX Live 2022 on Overleaf]
  • Package citation-style-language version: [e.g. v0.1.0, main branch]
  • LaTeX engine: [e.g. pdflatex / xelatex / lualatex]

To Reproduce

\documentclass{article}

\begin{filecontents}[overwrite, noheader]{\jobname.json}
[
    {
        "id": "ITEM-1",
        "type": "book",
        "author": [
            {
                "family": "D’Arcus",
                "given": "Bruce"
            }
        ],
        "issued": {
            "date-parts": [
                [
                    2005
                ]
            ]
        },
        "publisher": "Routledge",
        "title": "Boundaries of dissent: Protest and state power in the media age"
    }
]
\end{filecontents}

\usepackage[style = custom-style]{citation-style-language}
\addbibresource{\jobname.json}
\usepackage{hyperref}

\begin{document}
\cite{ITEM-1}
\printbibliography
\end{document}

The custom style

<?xml version="1.0" encoding="utf-8"?>
<style class="note" version="1.0" et-al-min="3" et-al-use-first="1" et-al-subsequent-min="3"
       et-al-subsequent-use-first="1" name-as-sort-order="first" page-range-format="expanded" default-locale="fr-FR"
       xmlns="http://purl.org/net/xbiblio/csl">
  <!-- This style was edited with the Visual CSL Editor (https://editor.citationstyles.org/visualEditor/) -->
  <info>
    <title>Université Catholique de Louvain - FIAL</title>
    <title-short>FIAL</title-short>
    <id>http://www.zotero.org/styles/universite-catholique-de-louvain-fial</id>
    <link href="http://www.zotero.org/styles/universite-catholique-de-louvain-fial" rel="self"/>
    <link href="http://zeus.fltr.ucl.ac.be/Harmonisation_bibliographique.pdf" rel="documentation" xml:lang="fr-FR"/>
    <author>
      <name>Edgar Pireyn</name>
      <email>[email protected]</email>
    </author>
    <category field="humanities" citation-format="note"/>
    <updated>2023-12-01T16:45:53+00:00</updated>
    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
  </info>
  <locale xml:lang="fr">
    <terms>
      <term name="ordinal">e</term>
      <term name="cited">op. cit.</term>
      <term name="editor" form="short">éd.</term>
      <term name="in">dans</term>
      <term name="translator">traduit par </term>
      <term name="director">dirigée par </term>
      <term name="ordinal-01" match="last-two-digits">er</term>
    </terms>
  </locale>
  <macro name="Author">
    <names variable="author" delimiter=", ">
      <name and="text" delimiter-precedes-last="never" initialize="false" initialize-with="." name-as-sort-order="all" sort-separator=" ">
        <name-part name="family" text-case="capitalize-first" font-variant="small-caps"/>
      </name>
      <substitute>
        <text macro="editor"/>
      </substitute>
    </names>
  </macro>
  <macro name="editor">
    <names variable="editor" delimiter=", ">
      <name and="text" delimiter-precedes-last="never" initialize="false" initialize-with="." name-as-sort-order="all" sort-separator=" ">
        <name-part name="family" text-case="capitalize-first" font-variant="small-caps"/>
      </name>
    </names>
    <text term="editor" form="short" prefix=" (" suffix=")"/>
  </macro>
  <macro name="translator">
    <text term="translator"/>
    <names variable="translator" font-variant="normal" delimiter=", ">
      <name and="text" delimiter-precedes-last="never" et-al-min="3" et-al-use-first="1" name-as-sort-order="all" sort-separator=" ">
        <name-part name="family" font-variant="normal"/>
      </name>
    </names>
  </macro>
  <macro name="Title">
    <group delimiter=", ">
      <choose>
        <if type="article-journal article-magazine article-newspaper entry-dictionary entry-encyclopedia chapter" match="any">
          <text macro="Title-in-title"/>
        </if>
        <else>
          <text variable="title" text-case="capitalize-first" font-style="italic"/>
        </else>
      </choose>
      <choose>
        <if type="thesis" match="any">
          <group delimiter=", ">
            <text variable="genre" text-case="capitalize-first"/>
            <choose>
              <if match="any" variable="director">
                <group delimiter=" ">
                  <text term="director"/>
                  <names variable="director" delimiter=",">
                    <name and="text" initialize="false" name-as-sort-order="all">
                      <name-part name="family" text-case="capitalize-first" font-variant="small-caps"/>
                    </name>
                  </names>
                </group>
              </if>
            </choose>
          </group>
        </if>
      </choose>
    </group>
  </macro>
  <macro name="Edition-Publisher-Issued">
    <group delimiter=", ">
      <choose>
        <if match="any" is-numeric="edition">
          <group delimiter=" ">
            <number variable="edition" form="ordinal"/>
            <text term="edition" form="short" vertical-align="baseline"/>
          </group>
        </if>
        <else>
          <text variable="edition" text-case="capitalize-first"/>
        </else>
      </choose>
      <text variable="publisher-place"/>
      <text variable="publisher"/>
      <choose>
        <if type="webpage post-weblog article-journal article-magazine article-newspaper" match="none">
          <choose>
            <if match="any" variable="issued">
              <choose>
                <if match="any" is-numeric="issued">
                  <date date-parts="year" form="text" variable="issued"/>
                </if>
                <else>
                  <date form="text" date-parts="year-month-day" variable="issued"/>
                </else>
              </choose>
            </if>
            <else>
              <text term="no date" form="short"/>
            </else>
          </choose>
        </if>
      </choose>
    </group>
  </macro>
  <macro name="Volume-Issue">
    <choose>
      <if match="none" variable="volume">
        <choose>
          <if match="any" is-numeric="number-of-volumes">
            <group delimiter=" ">
              <text variable="number-of-volumes"/>
              <text term="volume" form="short"/>
            </group>
          </if>
        </choose>
      </if>
    </choose>
    <group delimiter=", ">
      <group delimiter=", ">
        <choose>
          <if match="any" is-numeric="issue">
            <group>
              <text term="issue" form="short" suffix=" "/>
              <number variable="issue"/>
            </group>
          </if>
          <else>
            <text variable="issue" suffix="hello"/>
          </else>
        </choose>
      </group>
      <group>
        <choose>
          <if type="article-journal article-magazine article-newspaper" match="any">
            <date form="text" variable="issued"/>
          </if>
        </choose>
      </group>
    </group>
  </macro>
  <macro name="Page-URL">
    <group delimiter=", ">
      <text macro="Locator-or-Page"/>
      <group delimiter=", ">
        <choose>
          <if match="any" variable="URL">
            <text term="online" text-case="capitalize-first" prefix="[" suffix="]"/>
            <text variable="URL" prefix="&lt;" suffix="&gt;"/>
            <group delimiter=" " prefix="(" suffix=")">
              <text term="accessed" text-case="capitalize-first"/>
              <date form="text" variable="accessed"/>
            </group>
          </if>
        </choose>
      </group>
    </group>
  </macro>
  <macro name="Locator-or-Page">
    <choose>
      <if match="any" variable="locator">
        <text macro="Locator"/>
      </if>
      <else>
        <group delimiter=" ">
          <label variable="page" form="short"/>
          <text variable="page"/>
        </group>
      </else>
    </choose>
  </macro>
  <macro name="Locator">
    <group delimiter=" ">
      <label variable="locator" form="short"/>
      <text variable="locator"/>
    </group>
  </macro>
  <macro name="Archive">
    <group delimiter=", ">
      <text variable="publisher-place" font-variant="small-caps"/>
      <text variable="archive"/>
      <text variable="archive_location" font-style="italic"/>
      <text variable="source"/>
      <text variable="call-number"/>
      <text macro="Locator"/>
    </group>
  </macro>
  <macro name="Title-in-title">
    <group delimiter=", ">
      <text variable="title" text-case="capitalize-first" quotes="true"/>
      <choose>
        <if match="any" variable="container-author editor">
          <group delimiter=", ">
            <group delimiter=" ">
              <text term="in"/>
              <choose>
                <if type="chapter" match="all" variable="container-author">
                  <names variable="container-author" delimiter=", ">
                    <name and="text" delimiter-precedes-last="never" initialize="false" initialize-with="." name-as-sort-order="all" sort-separator=" ">
                      <name-part name="family" font-variant="small-caps"/>
                    </name>
                  </names>
                </if>
                <else-if match="any" variable="editor">
                  <text macro="editor"/>
                </else-if>
              </choose>
            </group>
            <text variable="container-title" text-case="title" font-style="italic"/>
          </group>
        </if>
        <else>
          <group delimiter=" ">
            <text term="in"/>
            <text variable="container-title" text-case="title" font-style="italic"/>
          </group>
        </else>
      </choose>
    </group>
  </macro>
  <macro name="Title-subsequent"/>
  <macro name="Volume-alpha">
    <choose>
      <if match="all" variable="volume">
        <group delimiter=" ">
          <number vertical-align="baseline" variable="volume"/>
          <text term="volume" form="short"/>
        </group>
      </if>
    </choose>
  </macro>
  <macro name="Collection">
    <group delimiter=", " prefix="(" suffix=")">
      <text variable="collection-title"/>
      <number prefix=" " variable="collection-number"/>
    </group>
  </macro>
  <citation et-al-min="4" et-al-use-first="1">
    <layout delimiter=" ">
      <group display="block" suffix=".">
        <choose>
          <if position="ibid-with-locator">
            <group delimiter=", " suffix=".">
              <text term="ibid" text-case="capitalize-first" font-style="italic" suffix="."/>
              <text macro="Locator"/>
            </group>
          </if>
          <else-if position="ibid">
            <text term="ibid" text-case="capitalize-first" font-style="italic"/>
          </else-if>
          <else-if position="subsequent">
            <group delimiter=", " suffix=".">
              <text macro="Author"/>
              <text macro="Title-subsequent"/>
              <text term="cited" text-case="lowercase" font-style="italic"/>
              <text macro="Locator"/>
            </group>
          </else-if>
          <else>
            <choose>
              <if type="manuscript" match="any">
                <text macro="Archive"/>
              </if>
              <else>
                <group delimiter=", ">
                  <text macro="Author"/>
                  <text macro="Title"/>
                  <text macro="Edition-Publisher-Issued"/>
                  <text macro="translator"/>
                  <text macro="Volume-alpha"/>
                  <text macro="Volume-Issue"/>
                  <text macro="Collection"/>
                  <text macro="Page-URL"/>
                </group>
              </else>
            </choose>
          </else>
        </choose>
      </group>
    </layout>
  </citation>
  <bibliography et-al-min="4" et-al-use-first="1">
    <sort>
      <key macro="Author"/>
      <key variable="issued" sort="descending"/>
      <key macro="Archive"/>
    </sort>
    <layout suffix=".">
      <choose>
        <if type="manuscript" match="any">
          <text macro="Archive"/>
        </if>
        <else>
          <group delimiter=", ">
            <text macro="Author"/>
            <text macro="Title"/>
            <text macro="translator"/>
            <text macro="Volume-alpha"/>
            <text macro="Edition-Publisher-Issued"/>
            <text macro="Volume-Issue"/>
            <text macro="Collection"/>
            <text macro="Page-URL"/>
          </group>
        </else>
      </choose>
    </layout>
  </bibliography>
</style>

Logs
test.log

Parsing of BibTeX files exported from Zotero using BetterBibLaTeX

Describe the bug

I've got a bug report from an user who exported his Zotero records using the BetterBibLaTeX plugin. He got a fatal error from the parsing of that file:

...ocal/texlive/2023/texmf-dist/tex/latex/base/ltluatex.lua:89: bad argument #1
 to 'sub' (string expected, got nil)
stack traceback:
        [C]: in function 'string.sub'
        ...ocal/texlive/2023/texmf-dist/tex/latex/base/ltluatex.lua:89: in upvalue 'ms
g_format'
        ...ocal/texlive/2023/texmf-dist/tex/latex/base/ltluatex.lua:105: in field 'mod
ule_warning'
        ...f-dist/scripts/citation-style-language/citeproc-util.lua:176: in function '
citeproc-util.warning'
        ...ripts/citation-style-language/citeproc-bibtex-parser.lua:340: in function '
citeproc-bibtex-parser.split_name_parts'
        .../scripts/citation-style-language/citeproc-bibtex2csl.lua:240: in function '
citeproc-bibtex2csl.convert_field'
        .../scripts/citation-style-language/citeproc-bibtex2csl.lua:101: in function '
citeproc-bibtex2csl.convert_to_csl_item'
        .../scripts/citation-style-language/citeproc-bibtex2csl.lua:75: in function 'c
iteproc-bibtex2csl.convert_to_csl_data'
        .../scripts/citation-style-language/citeproc-latex-core.lua:153: in upvalue 'r
ead_data_files'
        .../scripts/citation-style-language/citeproc-latex-core.lua:199: in function '
citeproc-latex-core.make_citeproc_sys'
        .../scripts/citation-style-language/citeproc-latex-core.lua:237: in function '
citeproc-latex-core.init'
        ...-dist/scripts/citation-style-language/citeproc-latex.lua:33: in function 'c
iteproc-latex.init'
        [\directlua]:1: in main chunk.
\lua_now:e #1->\__lua_now:n {#1}
                                
l.23 \begin{document}

I've found that this is caused by the author field, which looks like this:

author = {family=Geijersstam, given=V., prefix=af, useprefix=true and Kibur, M. and Wang, Z. and Koskela, P. and Pukkala, E. and Schiller, J. and Lehtinen, M. and Dillner, J.}

Additional information

  • TeX distribution: TeX Live 2023
  • Package citation-style-language version: 2023-10-05 v0.4.5
  • LaTeX engine: lualatex, pdflatex

To Reproduce

\documentclass{article}
\begin{filecontents}[overwrite, noheader]{\jobname.bib}
@article{afGeijersstam1998Stability,
  title = {Stability over Time of Serum Antibody Levels to Human Papillomavirus Type 16},
  author = {family=Geijersstam, given=V., prefix=af, useprefix=true and Kibur, M. and Wang, Z. and Koskela, P. and Pukkala, E. and Schiller, J. and Lehtinen, M. and Dillner, J.},
  date = {1998-06},
  journaltitle = {J Infect Dis},
  volume = {177},
  number = {6},
  eprint = {9607854},
  eprinttype = {pmid},
  pages = {1710--1714},
  issn = {0022-1899},
  doi = {10.1086/517428},
  abstract = {The stability over time of serum IgG antibody levels to human papillomavirus type 16 (HPV-16) was determined by comparing the HPV-16 capsid antibody levels in serial serum samples of an age-stratified random subsample of 1656 primiparous mothers resident in Helsinki who were followed until their second pregnancy, on average 29.5 months later. The correlation between the first and second pregnancy HPV-16 serum antibody levels of the same woman was high, even when {$>$}4 years had elapsed between pregnancies (r = .822). Between negativity, indeterminate results, or quartiles of positivity, the predictive values for being classified in the same category on both occasions ranged between 42\% and 91\%. Correlation coefficients, predictive values, and kappa coefficients between serial samples all were comparable with those of repeat analyses of the same sample, indicating that HPV capsid antibody levels are generally stable during several years of follow-up.},
  langid = {english},
  keywords = {Adolescent,Adult,Antibodies,Capsid,Capsid Proteins,Female,Humans,Infectious,Oncogene Proteins,Papillomaviridae,Papillomavirus Infections,Pregnancy,Pregnancy Complications,Time Factors,Tumor Virus Infections,Viral}
}
\end{filecontents}

\usepackage{citation-style-language}
\addbibresource{\jobname.bib}
\begin{document}
\cite{afGeijersstam1998Stability}
\printbibliography
\end{document}

With lualatex, you will get the original error. When compiled using

$ pdflatex mwe
$ citeproc-lua mwe

You will get:

This is citeproc-lua, Version 0.4.5
The top-level auxiliary file: mwe.aux
Database file #1: mwe.bib
...f-dist/scripts/citation-style-language/citeproc-util.lua:181: attempt to concatenate a nil value (local 'message')

Bug with cite position

Describe the bug
Two consecutive cites to the same reference are considered "subsequent" but not "Ibid (with locator)".
This happens when name-as-sort-order="all" and that the reference only has one author. It doesn't happen if it has more than one author or if name-as-sort-order="first".

Additional information

  • TeX distribution: MikTex 2023
  • Package citation-style-language version: main branch
  • LaTeX engine: xelatex

To Reproduce

\documentclass{article}

\begin{filecontents}[overwrite, noheader]{\jobname.json}
[
    {
    "ISBN": "9782200632694",
    "author": [
      {
        "family": "Amossy",
        "given": "Ruth"
      },
      {
        "family": "Pierrot",
        "given": "Anne Herschberg"
      }
    ],
    "collection-title": "Cursus",
    "edition": "4",
    "id": "Amossy2021",
    "issued": {
      "date-parts": [
        [
          2021,
          6,
          9
        ]
      ]
    },
    "keyword": "General, Language Arts & Disciplines, Social Science",
    "publisher": "Armand Colin",
    "publisher-place": "Paris",
    "title": "Stéréotypes et clichés : Langue, discours, société",
    "title-short": "Stéréotypes et clichés ",
    "type": "book"
  },
  {
    "ISBN": "2871300658",
    "author": [
      {
        "family": "Lits",
        "given": "Marc"
      }
    ],
    "collection-number": "4",
    "collection-title": "Bibliothèque des paralittératures",
    "edition": "2",
    "id": "Lits1999",
    "issued": {
      "date-parts": [
        [
          1999
        ]
      ]
    },
    "number-of-pages": "208",
    "publisher": "Éd. du CÉFAL",
    "publisher-place": "Liège",
    "title": "Le roman policier: Introduction à la théorie et à l’histoire d’un genre littéraire",
    "title-short": "Le roman policier",
    "type": "book"
  },
]
\end{filecontents}

\usepackage[style = chicago-note-bibliography]{citation-style-language}
\addbibresource{\jobname.json}
\usepackage{hyperref}

\begin{document}
This is the first cite\cite[page = 103--200]{Amossy2021}

This is the second cite\cite[page = 103--104]{Amossy2021}

These should be working correctly. But if I cite those two:

First\cite[page = 105--130]{Lits1999}

Second\cite[page = 105--130]{Lits1999}

The page range doesn't matter. It can be null, different or identical.

\printbibliography
\end{document}

Screenshots
image

Catch nil in PMID (citeproc-bibtex2csl.lua)

Describe the bug

Forgive me for not making a PR, but I believe you will be able to code a better solution if this needs patching. The cause may be due to my bib file being dirty rather than this being a bug in the code!

However, I patched citeproc-bibtex2csl.lua:

-  if bib_fields.eprint and string.lower(bib_fields.eprinttype) == "pubmed" and not item.PMID then
-    item.PMID = bib_fields.eprint

To:

+  if type(bib_fields.eprinttype) == "string" then
+    if bib_fields.eprint and string.lower(bib_fields.eprinttype) == "pubmed" and not item.PMID then
+      item.PMID = bib_fields.eprint
+    end
+  else
+    item.PMID = ""
+   end

This will catch bib entries which fail when string.lower(bib_fields.eprinttype) it is of type/value nil not string. This solved an error in my tex document.

Few issues with the LaTeX formatter

Hi, I've found few issues the text_escape function in the LaTeX formatter. One issue is fatal, there is a missing string concatenation in string.gsub. The second issue is missing escaping of the $ pattern, so it adds $ character at end of each string. So the example Lua script produces something like: (\$F.G.\$ \$Bennett\$ \$Jr.,\$ \$2009\$; \$B.\$ \$D’Arcus\$, \$2005\$)\$, for example.

Here is a patch that should fix these issues.

diff --git a/citeproc/citeproc-formats.lua b/citeproc/citeproc-formats.lua
index f22186f..6c998a8 100644
--- a/citeproc/citeproc-formats.lua
+++ b/citeproc/citeproc-formats.lua
@@ -61,7 +61,7 @@ formats.latex = {
   ["text_escape"] = function (str)
     str = str:gsub("\\", "\\textbackslash")
     str = str:gsub("#", "\\#")
-    str = str:gsub("$", "\\$")
+    str = str:gsub("%$", "\\$")
     str = str:gsub("%%", "\\%")
     str = str:gsub("&", "\\&")
     str = str:gsub("{", "\\{")
@@ -69,7 +69,7 @@ formats.latex = {
     str = str:gsub("_", "\\_")
     str = str:gsub(util.unicode["no-break space"], "~")
     for char, sub in pairs(util.superscripts) do
-      str = string.gsub(str, char, "\\textsuperscript{" .. sub "}")
+      str = string.gsub(str, char, "\\textsuperscript{" .. sub .. "}")
     end
     return str
   end,

Undefined control sequence when used with beamer

Describe the bug
"! Undefined control sequence.
\l__csl_citation_tl ->\cslcite
{McCarthy2007-Deut.}{Carmel McCarthy, ed., \t...
l.13 \end{frame}"

Additional information

  • TeX distribution: MacTeX 2023
  • Package citation-style-language version: 0.4.2
  • LaTeX engine: lualatex

To Reproduce
.tex file:

% !TEX encoding = UTF-8 Unicode
\documentclass[aspectratio=169]{beamer}

\usepackage{citation-style-language}
\cslsetup{style = turabian-fullnote-bibliography-no-ibid}
\addbibresource{myBib.json}

\begin{document}

\begin{frame}
\frametitle{Test MWE}
Hello\cite{McCarthy2007-Deut.}
\end{frame}

\end{document}

.json file:

[
    {
        "id": "McCarthy2007-Deut.",
        "type": "book",
        "editor": [
            {
                "family": "McCarthy",
                "given": "Carmel"
            }
        ],
        "collection-editor": [
            {
                "family": "Schenker",
                "given": "A."
            }
        ],
        "title": "Deuteronomy",
        "title-short": "Deut.",
        "source": "Accordance",
        "collection-title": "Biblia Hebraica Quinta",
        "collection-number": "5",
        "publisher-place": "Stuttgart",
        "publisher": "Deutsche Bibelgesellshaft",
        "issued": {
            "date-parts": [
                [
                    "2007"
                ]
            ]
        }
    }
]

Here is the output:
mwe.pdf

Document how to install the github version on top of the version onstalled by TeXLive

Perusing the project history shows that it evolves (and progresses) much faster than TeXLive (especially distribution-packaged versions of TeXLive...). However, how to to replace the TeXLive verison to the last Github version isn't absolutely obvious to the LaTeX end-user who would like to use the corrected/expanded/new features without diving in the finesses of Lua unit testing...

A small paragraph explaining how to install/uninstall rhe github version on top of TeXLive-installed one would be welcome...

Question: Is there an equivalent to the cites command?

^
desired outcome:

something relative to: https://tex.stackexchange.com/questions/18910/multiple-citations-with-pages-using-biblatex?noredirect=1&lq=1

I have read In other packages, several commands are provided for producing citations in different styles such as \citet, \citep, \parencite, and \footnotecite. In citation-style-language package, however, the format of citations is fixed as formatted in CSL style and it is impossible to select another format without modifying the .csl style file in the documentation.

Does this mean, it is absolutely impossible to cite multiple citations with pages?

Wrong bibcite commands with pdflatex

Hi, great to see that there will be robust CSL support in LaTeX because that is something that non-mathematician users have been asking for for a long time.

I have an issue when trying to compile the example with pdflatex: the .aux file looks like this,

\relax 
\bibstyle{molecular-ecology}
\bibdata{example.bib}
\citation{{}{}{ITEM-1}}
\citation{{}{}{ITEM-1,ITEM-2}}
\citation{{}{ 6}{ITEM-1}}
\citation{{prefix }{ suffix}{ITEM-1}}
\citation{{}{ suffix}{ITEM-1}}
\citation{{prefix }{}{ITEM-1}}
\bibcite{ITEM-1}{(D\OT1\textquoteright Arcus 2005)}
\bibcite{ITEM-1,ITEM-2}{(D\OT1\textquoteright Arcus 2005; Bennett 2009)}
\bibcite{ITEM-1}{(D\OT1\textquoteright Arcus 2005 p. 6)}
\bibcite{ITEM-1}{(prefix D\OT1\textquoteright Arcus 2005 suffix)}
\bibcite{ITEM-1}{(D\OT1\textquoteright Arcus 2005 suffix)}
\bibcite{ITEM-1}{(prefix D\OT1\textquoteright Arcus 2005)}
\gdef \@abspage@last{1}

with apparently encoding-related parts, and then obviously pdflatex complains about the command \OT being undefined. No issue when using lualatex though.

Prevent hyphenation of urls in references

When citeproc-lua with lualatex is used, the url gets hyphenated, which makes them unusable! I have provided a MWE here and can anyone please tell from where did (Original Work Published) come in the output?

\documentclass[12pt,abstract = true,toc = flat,toc = bib]{scrreprt}
\usepackage[english]{babel}
\usepackage[hidelinks]{hyperref}
\usepackage{citation-style-language}
\cslsetup{style = apa}
\addbibresource{example.bib}
\begin{filecontents}{example.bib}
@article{baillie_deliver_2021,
	title = {A Long url},
	url = {https://www.hydrocarbonprocessing.com/magazine/2021/september-2021/catalysts/deliver-high-levels-of-sox-reduction-with-sox-reduction-additive},
	journal = {this url gets hyphenated},
	author = {Test},
	month = march,
	year = {2022},
},
		@article{responsetoukaraniancrisis,
			title = {BAPS Responds to Ukrainian Humanitarian Crisis, Poland},
			url = {https://www.baps.org/Photos/2022/Emergency-Response-in-Rzesz243w-Poland-24266.aspx?mid=226449},
			journal = {BAPS News UK and Europe},
			author = {BAPS},
			month = march,
			year = {2022}
	}

\end{filecontents}
\begin{document}
	\nocite{*}
	\printbibliography
\end{document}

Output (check second reference)
2022-03-06 21_43_20-Greenshot

context integration

Wow, that's an interesting project. Do you think a context integration would be feasible?

DOI only converted to URL for first reference when also using package hyperref

I'm using APA style, with citation-style-language {2022-09-23} {v0.2.2} in TexLive 2022, and compiling with LuaLatex. DOIs should be converted to URLs in the reference list by prepending https://doi.org/ to the DOI. However, when package hyperref is also used, only the first reference in the list has https://doi.org/ prepended to the DOI. Here's a MRE:

\documentclass{article}
  
\begin{filecontents}[overwrite, noheader]{mwe-csl.bib}
@article{edge-garza.etal-2014-Mol.Breed.,
  title = {A high-throughput and cost-efficient {{DNA}} extraction protocol for the tree fruit crops of apple, sweet cherry, and peach relying on silica beads during tissue sampling},
  author = {Edge-Garza, Daniel A. and Rowland, Terrence V. and Haendiges, Stacey and Peace, Cameron},
  date = {2014-12-01},
  journaltitle = {Molecular Breeding},
  volume = {34},
  number = {4},
  pages = {2225--2228},
  issn = {1380-3743, 1572-9788},
  doi = {10.1007/s11032-014-0160-x},
}

@article{paris.etal-2017-MethodsEcolEvola,
  title = {Lost in parameter space: {{A}} road map for {{Stacks}}},
  shorttitle = {Lost in parameter space},
  author = {Paris, Josephine R and Stevens, Jamie R and Catchen, Julian M},
  date = {2017-03-01},
  journaltitle = {Methods in Ecology and Evolution},
  shortjournal = {Methods Ecol Evol},
  volume = {8},
  pages = {1360--1373},
  issn = {2041-210X},
  doi = {10.1111/2041-210X.12775},
}

@article{peterson.etal-2012-PLoSONE,
  title = {Double digest {{RADseq}}: an inexpensive method for de novo {{SNP}} discovery and genotyping in model and non-model species},
  shorttitle = {Double {{Digest RADseq}}},
  author = {Peterson, Brant K. and Weber, Jesse N. and Kay, Emily H. and Fisher, Heidi S. and Hoekstra, Hopi E.},
  date = {2012-05-31},
  journaltitle = {PLoS ONE},
  volume = {7},
  number = {5},
  pages = {e37135},
  issn = {1932-6203},
  doi = {10.1371/journal.pone.0037135},
}
\end{filecontents}

\usepackage{citation-style-language}
\cslsetup{style = apa}
\addbibresource{mwe-csl.bib}

\usepackage{hyperref}

\begin{document}

        First citation \cite{edge-garza.etal-2014-Mol.Breed.}.

        Second citation \cite{peterson.etal-2012-PLoSONE}.

        Third citation \cite{paris.etal-2017-MethodsEcolEvola}.

        \printbibliography

\end{document}

Pass item table to @bibliography/entry formatter

In LaTeX formatter, we need the item.id field in order to construct the \bibitem command. It is used traditionally in thebibliography for cross-referencing. You can then jump from the \cite command in the document directly to the bibliography.

I think it is just necessary to change the linek 651 in node.lua to:

    res = self:get_engine().formatter["@bibliography/entry"](res,item)

BTW, if you intend to publish this package to CTAN, it may be a good idea to rename the Lua files to citeproc-node.lua, citeproc-formatter.lua, etc. They have the policy of using prefixes to prevent filename clashes. I had to rename some of my projects in the past because of this.

Zotero integration

I understand that CSL is not constrained to Zotero, still I wonder whether some kind of integration is planned. I am merely thinking of two areas:

  • Accessing Zotero bibliographic data. This would massively facilitate the ability to use the same data with different tools/writing apps.

  • Accessing the CSL styles installed by Zotero. This would eliminate the need to have all auxiliary files installed two times.

Modification of citeproc-bib.lua to support German umlaute

Hey,

great project, thank you for sharing it! In order to use it for German references, I had to modify citeproc-bib.lua and thought you might be interested in my code as you left a "-- TODO: unicode chars like "{o}" in bib.unescape. So here's my simple code inserted below that TODO:
str = string.gsub(str, "\"o", "ö")
str = string.gsub(str, "\"a", "ä")
str = string.gsub(str, "\"u", "ü")
str = string.gsub(str, "\"O", "Ö")
str = string.gsub(str, "\"A", "Ä")
str = string.gsub(str, "\"U", "Ü")

Additionally, I found that str = string.gsub(str, "\%%", "%") leads to this error for some files: "...mf-dist/scripts/citation-style-language/citeproc-bib.lua:158: invalid use of '%' in replacement string", where line 158 is str = string.gsub(str, "\%%", "%"). My quick fix was to simply comment it out, but I guess you can do better than me and maybe fix that issue? :)

Cheers

Lua-UCA support

Hi, here is a patch for citeproc-node-sort.lua that adds support for sorting using Lua-UCA. One thing that is missing is the language setting interface. The code expects bibliography language setting in context.lang, but you may want to name it differently. A function that will set it will be necessary.

diff --git a/citeproc/citeproc-node-sort.lua b/citeproc/citeproc-node-sort.lua
index 5370558..85bb6df 100644
--- a/citeproc/citeproc-node-sort.lua
+++ b/citeproc/citeproc-node-sort.lua
@@ -2,6 +2,13 @@ local Element = require("citeproc.citeproc-node-element")
 local Names = require("citeproc.citeproc-node-names").names
 local util = require("citeproc.citeproc-util")
 
+-- UCA collation support
+local ducet = require "lua-uca.lua-uca-ducet"
+local collator = require "lua-uca.lua-uca-collator"
+local languages = require "lua-uca.lua-uca-languages"
+
+local collator_obj = collator.new(ducet)
+
 
 local Sort = Element:new()
 
@@ -26,24 +33,22 @@ function Sort:sort (items, context)
       table.insert(key_dict[item.id], value)
     end
   end
+  local lang = context.lang or "en"
+  local language_sort = languages[lang] 
+  local collator = collator_obj
+  -- use language specific sorting, if available
+  if language_sort then 
+    collator = language_sort(collator_obj)
+  end
   local compare_entry = function (item1, item2)
     for i, value1 in ipairs(key_dict[item1.id]) do
       local descending = descendings[i]
       local value2 = key_dict[item2.id][i]
       if value1 and value2 then
-        if value1 < value2 then
-          if descending then
-            return false
-          else
-            return true
-          end
-        elseif value1 > value2 then
-          if descending then
-            return true
-          else
-            return false
-          end
-        end
+        local result = collator:compare_strings(value1, value2)
+        -- reverse sorting in descending mode
+        if descending then result = not(result) end
+        return result
       elseif value1 then
         return true
       elseif value2 then

Cite error with commands in prefix

This is my JSON file:

[
    {
        "id": "Williams1992-Heaven20",
        "type": "article-journal",
        "author": [
            {
                "family": "Williams",
                "given": "Michael"
            }
        ],
        "title": "Of Heaven and History: The Verticalist Eschatology of Geerhardus Vos",
        "title-short": "Heaven and History",
        "volume": "20",
        "issue": "3",
        "container-title": "Pro Rege",
        "page": "9-18",
        "URL": "https://digitalcollections.dordt.edu/pro_rege",
        "issued": {
            "date-parts": [
                [
                    "1992"
                ]
            ]
        },
        "accessed": {
            "date-parts": [
                [
                    "2022",
                    "12",
                    "13"
                ]
            ]
        }
    }
]

The following code produces the right (expected) output:

% !TEX encoding = UTF-8 Unicode
\documentclass[12pt,oneside]{article}
\usepackage{citation-style-language}
\cslsetup{style = chicago-fullnote-bibliography}
\addbibresource{myBib.json}
\begin{document}
test.\cite[prefix = {See the opposite view in },
page = 1]{Williams1992-Heaven20}
\newpage
\printbibliography
\end{document}

The following code (with the command in the prefix) fails to produce a footnote or final reference:

% !TEX encoding = UTF-8 Unicode
\documentclass[12pt,oneside]{article}
\usepackage{citation-style-language}
\cslsetup{style = chicago-fullnote-bibliography}
\addbibresource{myBib.json}
\begin{document}
test.\cite[prefix = {See the \textit{opposite} view in },
page = 1]{Williams1992-Heaven20}
\newpage
\printbibliography
\end{document}

Thanks,
Nick

Change headings font size and margin

I've ran into the problem that I wanted to get the heading of \printbibliography to another font size and remove the space between page top and heading.

Is there any command to do this?

Thank you very much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.