zepinglee / citeproc-lua

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

Pass item table to @bibliography/entry formatter #2

Closed michal-h21 closed 2 years ago

michal-h21 commented 2 years ago

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.

zepinglee commented 2 years ago

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.

Yep.

There are still problems with author-date citations. In the natbib solution, the \bibitem provides author names and year in its optional argument (e.g., \bibitem[author(year)full authors]{key}) for rendering the citation. But citeproc directly outputs the fomatted citation with more features like disambiguation. I've not figured out how to interact with LaTeX. At the time being, the main developing task is to provide the primary features of the engine for practical use.

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.

Thanks for reminding. I hope to publish the package to both CTAN and luarocks. The files will be renamed like this.

.
├── citeproc
│   ├── citeproc.lua
│   ├── citeproc-node.lua
│   ├── citeproc-format.lua
│   └── citeproc-util.lua
└── test
    ├── citeproc-test.lua
    └── test-suite
michal-h21 commented 2 years ago

There are still problems with author-date citations. In the natbib solution, the \bibitem provides author names and year in its optional argument (e.g., \bibitem[author(year)full authors]{key}) for rendering the citation. But citeproc directly outputs the fomatted citation with more features like disambiguation. I've not figured out how to interact with LaTeX. At the time being, the main developing task is to provide the primary features of the engine for practical use.

Yes, citations in text will be complicated, as you need to support different styles, not only author-year, but also footnotes, styles that make shortcuts for subsequent citations, etc. I guess that it shouldn't be that hard to support all of this in LuaLaTeX, but if you want to support other engines, it will be more difficult.

Thanks for reminding. I hope to publish the package to both CTAN and luarocks. The files will be renamed like this.

Great! I've had quite hard time several times in the past because of this issue. I always forgot about it.